DriveFileRevision#
- class nominal.experimental.drives.DriveFileRevision(rid, file_rid, path, size_bytes, state, download_availability, created_at, created_by_rid)#
Bases:
HasRidOne entry in a managed file’s linear history.
A revision records either a content change (
stateisDriveFileState.ACTIVE) or a removal (stateisDriveFileState.REMOVED), which is how a removal is distinguished from a new version.- state: DriveFileState#
- download_availability: DownloadAvailability#
Whether the observed content can be downloaded.
- created_at: IntegralNanosecondsUTC | None#
- download(output_directory, *, part_size=DEFAULT_CHUNK_SIZE, num_retries=3)#
Download this revision’s content into a directory.
- Parameters:
- Returns:
Path the file was written to.
- Raises:
ValueError – The revision’s filename would not stay inside
output_directory, for example because it contains a backslash.NotADirectoryError –
output_directoryexists but is not a directory.FileNotFoundError –
output_directorydoes not exist.FileExistsError – A file already exists at the destination.
NominalNotFoundError – This revision’s bytes are no longer retained.
- Return type:
- restore(destination)#
Reinstate this revision’s content at a destination.
- Parameters:
destination (str | ManagedDriveFile | DriveFileRevision)
Where to place the restored content. If the owning file is still active, this must replace that file; if it was removed, a free path works.
- Returns:
The file as it now stands.
- Raises:
ValueError –
destinationis a file or revision from a different drive.NominalFileStoreError – The restore was rejected — for example the destination path is occupied, or the file it targets has moved on.
- Return type:
Note
File changes are not automatically replayed after transport errors, which can leave the outcome unknown. See Recover after a transport error before retrying.