Fix directory moves on backup migration

This commit is contained in:
amcmanu3 2024-07-29 18:02:00 -04:00
parent 627adcdc95
commit ff9abe4359
2 changed files with 6 additions and 10 deletions

View File

@ -183,8 +183,7 @@ class FileHelpers:
@staticmethod
def move_dir(src_path, dest_path):
FileHelpers.copy_dir(src_path, dest_path)
FileHelpers.del_dirs(src_path)
shutil.move(src_path, dest_path)
@staticmethod
def move_dir_exist(src_path, dest_path):
@ -193,8 +192,7 @@ class FileHelpers:
@staticmethod
def move_file(src_path, dest_path):
FileHelpers.copy_file(src_path, dest_path)
FileHelpers.del_file(src_path)
shutil.move(src_path, dest_path)
@staticmethod
def make_archive(path_to_destination, path_to_zip, comment=""):

View File

@ -175,12 +175,10 @@ def migrate(migrator: Migrator, database, **kwargs):
Helpers.ensure_dir_exists(
os.path.join(server.backup_path, new_backup.backup_id)
)
for file in os.listdir(server.backup_path):
if not os.path.isdir(os.path.join(os.path.join(server.backup_path, file))):
FileHelpers.move_file(
os.path.join(server.backup_path, file),
os.path.join(server.backup_path, new_backup.backup_id, file),
)
FileHelpers.move_dir(
os.path.join(server.backup_path),
os.path.join(server.backup_path, new_backup.backup_id),
)
Console.debug("Migrations: Dropping old backup table")
# Drop the existing backups table