From d90080f325f0217d2f63ff6b58f4d7a80de448c5 Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Mon, 8 Feb 2021 22:49:01 +0100 Subject: [PATCH] only move files if necessary --- src/documents/migrations/1012_fix_archive_files.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/documents/migrations/1012_fix_archive_files.py b/src/documents/migrations/1012_fix_archive_files.py index e95715265..98794aad0 100644 --- a/src/documents/migrations/1012_fix_archive_files.py +++ b/src/documents/migrations/1012_fix_archive_files.py @@ -163,8 +163,9 @@ def move_new_to_old_locations(apps, schema_editor): for doc in Document.objects.filter(archive_checksum__isnull=False): new_archive_path = archive_path_new(doc) old_archive_path = archive_path_old(doc) - shutil.move(new_archive_path, old_archive_path) - logger.debug(f"Moving {new_archive_path} to {old_archive_path}") + if new_archive_path != old_archive_path: + logger.debug(f"Moving {new_archive_path} to {old_archive_path}") + shutil.move(new_archive_path, old_archive_path) class Migration(migrations.Migration):