This commit is contained in:
Edwin Eefting 2021-04-17 22:33:12 +02:00
parent 488ff6f551
commit 352d5e6094

View File

@ -162,26 +162,27 @@ class ZfsDataset:
else: else:
return ZfsDataset(self.zfs_node, self.rstrip_path(1)) return ZfsDataset(self.zfs_node, self.rstrip_path(1))
def find_prev_snapshot(self, snapshot, also_other_snapshots=False): # NOTE: unused for now
"""find previous snapshot in this dataset. None if it doesn't exist. # def find_prev_snapshot(self, snapshot, also_other_snapshots=False):
# """find previous snapshot in this dataset. None if it doesn't exist.
also_other_snapshots: set to true to also return snapshots that where #
not created by us. (is_ours) # also_other_snapshots: set to true to also return snapshots that where
# not created by us. (is_ours)
Args: #
:type snapshot: str or ZfsDataset.ZfsDataset # Args:
:type also_other_snapshots: bool # :type snapshot: str or ZfsDataset.ZfsDataset
""" # :type also_other_snapshots: bool
# """
if self.is_snapshot: #
raise (Exception("Please call this on a dataset.")) # if self.is_snapshot:
# raise (Exception("Please call this on a dataset."))
index = self.find_snapshot_index(snapshot) #
while index: # index = self.find_snapshot_index(snapshot)
index = index - 1 # while index:
if also_other_snapshots or self.snapshots[index].is_ours(): # index = index - 1
return self.snapshots[index] # if also_other_snapshots or self.snapshots[index].is_ours():
return None # return self.snapshots[index]
# return None
def find_next_snapshot(self, snapshot, also_other_snapshots=False): def find_next_snapshot(self, snapshot, also_other_snapshots=False):
"""find next snapshot in this dataset. None if it doesn't exist """find next snapshot in this dataset. None if it doesn't exist