DriveFileRevision#

class nominal.experimental.drives.DriveFileRevision(rid, file_rid, path, size_bytes, state, download_availability, created_at, created_by_rid)#

Bases: HasRid

One entry in a managed file’s linear history.

A revision records either a content change (state is DriveFileState.ACTIVE) or a removal (state is DriveFileState.REMOVED), which is how a removal is distinguished from a new version.

rid: str#
file_rid: str#
path: str#

Path at which this revision became current.

size_bytes: int#
state: DriveFileState#
download_availability: DownloadAvailability#

Whether the observed content can be downloaded.

created_at: IntegralNanosecondsUTC | None#
created_by_rid: str | None#
download(output_directory, *, part_size=DEFAULT_CHUNK_SIZE, num_retries=3)#

Download this revision’s content into a directory.

Parameters:
  • output_directory (Path | str)

    Directory to write into. The file is named after this revision’s path.

  • part_size (int)

    Size in bytes of each ranged download request.

  • num_retries (int)

    Retries per part.

Returns:

Path the file was written to.

Raises:
Return type:

Path

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 – destination is 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:

ManagedDriveFile

Note

File changes are not automatically replayed after transport errors, which can leave the outcome unknown. See Recover after a transport error before retrying.