diff options
| author | Glenn Smith <glenn@vector35.com> | 2021-12-09 17:58:16 -0500 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2022-01-20 15:13:42 -0500 |
| commit | 5e98f8607c6d8ccd17601d00a479c8ce3dc35890 (patch) | |
| tree | b1ef938c7451449832a96b74e47ed5303779e70b /python/database.py | |
| parent | 82dd03bf69c53650c99461a02163df53be41e951 (diff) | |
[Enterprise] Support for sparse/trimmed snapshots
Diffstat (limited to 'python/database.py')
| -rw-r--r-- | python/database.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/python/database.py b/python/database.py index ba6943a8..a563d99c 100644 --- a/python/database.py +++ b/python/database.py @@ -149,6 +149,16 @@ class Snapshot: return core.BNIsSnapshotAutoSave(self.handle) @property + def has_contents(self) -> bool: + """If the snapshot has contents, and has not been trimmed (read-only)""" + return core.BNSnapshotHasContents(self.handle) + + @property + def has_undo(self) -> bool: + """If the snapshot has undo data (read-only)""" + return core.BNSnapshotHasUndo(self.handle) + + @property def first_parent(self) -> Optional['Snapshot']: """Get the first parent of the snapshot, or None if it has no parents (read-only)""" handle = core.BNGetSnapshotFirstParent(self.handle) @@ -189,6 +199,7 @@ class Snapshot: @property def file_contents(self) -> databuffer.DataBuffer: """Get a buffer of the raw data at the time of the snapshot (read-only)""" + assert self.has_contents handle = core.BNGetSnapshotFileContents(self.handle) assert handle is not None return databuffer.DataBuffer(handle=handle) @@ -196,6 +207,7 @@ class Snapshot: @property def file_contents_hash(self) -> databuffer.DataBuffer: """Get a hash of the data at the time of the snapshot (read-only)""" + assert self.has_contents handle = core.BNGetSnapshotFileContentsHash(self.handle) assert handle is not None return databuffer.DataBuffer(handle=handle) @@ -203,11 +215,13 @@ class Snapshot: @property def undo_entries(self): """Get a list of undo entries at the time of the snapshot (read-only)""" + assert self.has_undo raise NotImplementedError("GetUndoEntries is not implemented in python") @property def data(self) -> KeyValueStore: """Get the backing kvs data with snapshot fields (read-only)""" + assert self.has_contents handle = core.BNReadSnapshotData(self.handle) assert handle is not None return KeyValueStore(handle=handle) |
