# 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`](https://dev.nominal.io/python/ref/generated/nominal.experimental.drives.DriveFileState.md#nominal.experimental.drives.DriveFileState.ACTIVE "nominal.experimental.drives.DriveFileState.ACTIVE")) or a
removal (`state` is [`DriveFileState.REMOVED`](https://dev.nominal.io/python/ref/generated/nominal.experimental.drives.DriveFileState.md#nominal.experimental.drives.DriveFileState.REMOVED "nominal.experimental.drives.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*](https://docs.python.org/3/library/pathlib.html#pathlib.Path "(in Python v3.15)") *|* [*str*](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))

      Directory to write into. The file is named after this
      revision’s path.
    - **part_size** ([*int*](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)"))

      Size in bytes of each ranged download request.
    - **num_retries** ([*int*](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)"))

      Retries per part.

Returns:
:   Path the file was written to.

Raises:
:   - [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError "(in Python v3.15)") – The revision’s filename would not stay inside `output_directory`,
      for example because it contains a backslash.
    - [**NotADirectoryError**](https://docs.python.org/3/builtins/exceptions.html#NotADirectoryError "(in Python v3.15)") – `output_directory` exists but is not a directory.
    - [**FileNotFoundError**](https://docs.python.org/3/builtins/exceptions.html#FileNotFoundError "(in Python v3.15)") – `output_directory` does not exist.
    - [**FileExistsError**](https://docs.python.org/3/builtins/exceptions.html#FileExistsError "(in Python v3.15)") – A file already exists at the destination.
    - [**NominalNotFoundError**](https://dev.nominal.io/python/ref/generated/nominal.exceptions.NominalNotFoundError.md#nominal.exceptions.NominalNotFoundError "nominal.exceptions.NominalNotFoundError") – This revision’s bytes are no longer retained.

Return type:
:   [*Path*](https://docs.python.org/3/library/pathlib.html#pathlib.Path "(in Python v3.15)")

### restore(destination)

Reinstate this revision’s content at a destination.

Parameters:
:   **destination** ([*str*](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") *|* [*ManagedDriveFile*](https://dev.nominal.io/python/ref/generated/nominal.experimental.drives.ManagedDriveFile.md#nominal.experimental.drives.ManagedDriveFile "nominal.experimental.drives.file.ManagedDriveFile") *|* [*DriveFileRevision*](https://dev.nominal.io/python/ref/generated/nominal.experimental.drives.DriveFileRevision.md#nominal.experimental.drives.DriveFileRevision "nominal.experimental.drives.file.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**](https://docs.python.org/3/builtins/exceptions.html#ValueError "(in Python v3.15)") – `destination` is a file or revision from a different drive.
    - [**NominalFileStoreError**](https://dev.nominal.io/python/ref/generated/nominal.experimental.drives.NominalFileStoreError.md#nominal.experimental.drives.NominalFileStoreError "nominal.experimental.drives.NominalFileStoreError") – The restore was rejected — for example the destination
      path is occupied, or the file it targets has moved on.

Return type:
:   [*ManagedDriveFile*](https://dev.nominal.io/python/ref/generated/nominal.experimental.drives.ManagedDriveFile.md#nominal.experimental.drives.ManagedDriveFile "nominal.experimental.drives.file.ManagedDriveFile")

> **Note**
>
> File changes are not automatically replayed after transport errors, which can leave
> the outcome unknown. See [Recover after a transport error](https://dev.nominal.io/python/guides/drives/overview.md#drive-change-retries) before retrying.
