From 73db2751b8590aa71b494b3e69374ab05f3d065d Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Mon, 29 Oct 2018 20:21:41 +0000 Subject: [PATCH] storage/reflink: make resize()/import_volume() more readable --- qubes/storage/reflink.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/qubes/storage/reflink.py b/qubes/storage/reflink.py index 262573ec..fd4d4ee5 100644 --- a/qubes/storage/reflink.py +++ b/qubes/storage/reflink.py @@ -264,13 +264,14 @@ class ReflinkVolume(qubes.storage.Volume): try: # assume volume is not (cleanly) stopped ... _resize_file(self._path_dirty, size) - self.size = size + update = True except FileNotFoundError: # ... but it actually is. _resize_file(self._path_clean, size) - self.size = size - return self + update = False - _update_loopdev_sizes(self._path_dirty) + self.size = size + if update: + _update_loopdev_sizes(self._path_dirty) return self def export(self): @@ -301,11 +302,11 @@ class ReflinkVolume(qubes.storage.Volume): if not self.save_on_stop: return self try: + success = False _copy_file(src_volume.export(), self._path_import) - except: - self._import_data_end(False) - raise - self._import_data_end(True) + success = True + finally: + self._import_data_end(success) return self def _path_revision(self, number, timestamp=None):