From dc94c2df485e58af223dedf997b1735b2500ca02 Mon Sep 17 00:00:00 2001 From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Sun, 6 Oct 2024 12:33:00 -0700 Subject: [PATCH] For extra peace of mind, get the file lock before updating storage paths --- .../migrations/1055_alter_storagepath_path.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/documents/migrations/1055_alter_storagepath_path.py b/src/documents/migrations/1055_alter_storagepath_path.py index cfa581b5d..8231aacd7 100644 --- a/src/documents/migrations/1055_alter_storagepath_path.py +++ b/src/documents/migrations/1055_alter_storagepath_path.py @@ -1,18 +1,18 @@ # Generated by Django 5.1.1 on 2024-10-03 14:47 +from django.conf import settings from django.db import migrations from django.db import models from django.db import transaction +from filelock import FileLock + +from documents.templating.utils import convert_format_str_to_template_format def convert_from_format_to_template(apps, schema_editor): - # TODO: Is there a signal to disable? I don't want documents getting moved while this is running - StoragePath = apps.get_model("documents", "StoragePath") - from documents.templating.utils import convert_format_str_to_template_format - - with transaction.atomic(): + with transaction.atomic(), FileLock(settings.MEDIA_LOCK): for storage_path in StoragePath.objects.all(): storage_path.path = convert_format_str_to_template_format(storage_path.path) storage_path.save()