From 5e98f8607c6d8ccd17601d00a479c8ce3dc35890 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Thu, 9 Dec 2021 17:58:16 -0500 Subject: [Enterprise] Support for sparse/trimmed snapshots --- python/database.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'python') diff --git a/python/database.py b/python/database.py index ba6943a8..a563d99c 100644 --- a/python/database.py +++ b/python/database.py @@ -148,6 +148,16 @@ class Snapshot: """If the snapshot was the result of an auto-save (read-only)""" 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)""" @@ -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) -- cgit v1.3.1