storage/reflink: simplify

This commit is contained in:
Rusty Bird 2018-03-11 15:35:00 +00:00
parent c382eb3752
commit 31810db977
No known key found for this signature in database
GPG Key ID: 469D78F47AAF2ADF

View File

@ -117,8 +117,7 @@ class ReflinkVolume(qubes.storage.Volume):
def verify(self): def verify(self):
if self.snap_on_start: if self.snap_on_start:
# pylint: disable=protected-access img = self.source._path_clean # pylint: disable=protected-access
img = self.source._path_clean
elif self.save_on_stop: elif self.save_on_stop:
img = self._path_clean img = self._path_clean
else: else:
@ -133,15 +132,11 @@ class ReflinkVolume(qubes.storage.Volume):
''' Drop volume object from pool; remove volume images from ''' Drop volume object from pool; remove volume images from
oldest to newest; remove empty VM directory. oldest to newest; remove empty VM directory.
''' '''
with suppress(KeyError): self.pool._volumes.pop(self, None) # pylint: disable=protected-access
# pylint: disable=protected-access
del self.pool._volumes[self]
self._prune_revisions(keep=0) self._prune_revisions(keep=0)
_remove_file(self._path_clean) _remove_file(self._path_clean)
_remove_file(self._path_dirty) _remove_file(self._path_dirty)
_remove_empty_dir(os.path.dirname(self._path_dirty)) _remove_empty_dir(os.path.dirname(self._path_dirty))
return self return self
def is_outdated(self): def is_outdated(self):
@ -172,8 +167,7 @@ class ReflinkVolume(qubes.storage.Volume):
self._commit() self._commit()
else: else:
_remove_file(self._path_dirty) _remove_file(self._path_dirty)
if self.snap_on_start: _remove_file(self._path_clean)
_remove_file(self._path_clean)
return self return self
def _commit(self): def _commit(self):