qubes/storage: unify _remove_if_exists argument type
In some places full volume object was called, in others - just file path. Since this function is also used in some volume init/teardown, use path everywhere.
This commit is contained in:
parent
574834ac68
commit
0a21300872
@ -109,9 +109,10 @@ class FilePool(Pool):
|
|||||||
|
|
||||||
def remove(self, volume):
|
def remove(self, volume):
|
||||||
if volume.volume_type in ['read-write', 'volatile']:
|
if volume.volume_type in ['read-write', 'volatile']:
|
||||||
_remove_if_exists(volume)
|
_remove_if_exists(volume.path)
|
||||||
elif volume.volume_type == 'origin':
|
elif volume.volume_type == 'origin':
|
||||||
_remove_if_exists(volume)
|
_remove_if_exists(volume.path)
|
||||||
|
_remove_if_exists(volume.path_cow)
|
||||||
|
|
||||||
def rename(self, volume, old_name, new_name):
|
def rename(self, volume, old_name, new_name):
|
||||||
assert issubclass(volume.__class__, FileVolume)
|
assert issubclass(volume.__class__, FileVolume)
|
||||||
@ -188,7 +189,7 @@ class FilePool(Pool):
|
|||||||
|
|
||||||
assert volume.size
|
assert volume.size
|
||||||
|
|
||||||
_remove_if_exists(volume)
|
_remove_if_exists(volume.path)
|
||||||
|
|
||||||
with open(volume.path, "w") as f_volatile:
|
with open(volume.path, "w") as f_volatile:
|
||||||
f_volatile.truncate(volume.size)
|
f_volatile.truncate(volume.size)
|
||||||
@ -412,7 +413,7 @@ class VolatileFile(SizeMixIn):
|
|||||||
|
|
||||||
def rename_target_dir(self, new_dir):
|
def rename_target_dir(self, new_dir):
|
||||||
''' Called by :py:class:`FilePool` when a domain changes it's name '''
|
''' Called by :py:class:`FilePool` when a domain changes it's name '''
|
||||||
_remove_if_exists(self)
|
_remove_if_exists(self.path)
|
||||||
file_name = os.path.basename(self.path)
|
file_name = os.path.basename(self.path)
|
||||||
self.target_dir = new_dir
|
self.target_dir = new_dir
|
||||||
new_path = os.path.join(new_dir, file_name)
|
new_path = os.path.join(new_dir, file_name)
|
||||||
@ -502,11 +503,9 @@ def copy_file(source, destination):
|
|||||||
destination))
|
destination))
|
||||||
|
|
||||||
|
|
||||||
def _remove_if_exists(volume):
|
def _remove_if_exists(path):
|
||||||
if os.path.exists(volume.path):
|
if os.path.exists(path):
|
||||||
os.remove(volume.path)
|
os.remove(path)
|
||||||
if volume.volume_type == 'origin':
|
|
||||||
os.remove(volume.path_cow)
|
|
||||||
|
|
||||||
|
|
||||||
def _check_path(path):
|
def _check_path(path):
|
||||||
|
Loading…
Reference in New Issue
Block a user