summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2021-12-09 17:58:16 -0500
committerGlenn Smith <glenn@vector35.com>2022-01-20 15:13:42 -0500
commit5e98f8607c6d8ccd17601d00a479c8ce3dc35890 (patch)
treeb1ef938c7451449832a96b74e47ed5303779e70b /python
parent82dd03bf69c53650c99461a02163df53be41e951 (diff)
[Enterprise] Support for sparse/trimmed snapshots
Diffstat (limited to 'python')
-rw-r--r--python/database.py14
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)