Skip to content

Commit

Permalink
Right way to handle backups dir and macct files.
Browse files Browse the repository at this point in the history
  • Loading branch information
kiarn committed Dec 18, 2021
1 parent 0091a1a commit ffd703a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions usr/lib/linuxmuster-webui/plugins/lmn_linbo4/images.py
Expand Up @@ -11,10 +11,11 @@

# Filenames like ubuntu.qcow2.desc
EXTRA_IMAGE_FILES = ['desc', 'info', 'vdi']
EXTRA_NONEDITABLE_IMAGE_FILES = ['torrent', 'macct']
EXTRA_NONEDITABLE_IMAGE_FILES = ['torrent']

# Filenames like ubuntu.reg
EXTRA_COMMON_FILES = ['reg', 'postsync', 'prestart']
EXTRA_NONEDITABLE_COMMON_FILES = ['macct']

EXTRA_PERMISSIONS_MAPPING = {
'desc': 0o664,
Expand Down Expand Up @@ -119,7 +120,7 @@ def delete_files(self):
if os.path.exists(path):
os.unlink(path)

for extra in EXTRA_COMMON_FILES:
for extra in EXTRA_COMMON_FILES + EXTRA_NONEDITABLE_COMMON_FILES:
path = os.path.join(self.path, f"{self.name}.{extra}")
if os.path.exists(path):
os.unlink(path)
Expand Down Expand Up @@ -167,7 +168,7 @@ def rename(self, new_name):

os.rename(actual, os.path.join(self.path, f"{new_image_name}.{extra}"))

for extra in EXTRA_COMMON_FILES:
for extra in EXTRA_COMMON_FILES + EXTRA_NONEDITABLE_COMMON_FILES:
actual = os.path.join(self.path, f"{self.name}.{extra}")
if os.path.exists(actual):
os.rename(actual, os.path.join(self.path, f"{new_name}.{extra}"))
Expand Down Expand Up @@ -285,7 +286,9 @@ def delete(self):
for timestamp, backup in self.backups.items():
backup.delete()

os.rmdir(self.backup_path)
if os.path.isdir(self.backup_path):
os.rmdir(self.backup_path)

self.base.delete()

def to_dict(self):
Expand Down

0 comments on commit ffd703a

Please sign in to comment.