From a6cebff7204f11b172ff9102ab8ecbbce1cef812 Mon Sep 17 00:00:00 2001 From: Martin Varga Date: Thu, 26 Sep 2024 12:07:32 +0200 Subject: [PATCH 1/2] Make sure moving temp works with live and geodiff dirs --- server/mergin/sync/storages/disk.py | 7 +++---- server/mergin/tests/test_celery.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/server/mergin/sync/storages/disk.py b/server/mergin/sync/storages/disk.py index 8c89f2bb..cab16d43 100644 --- a/server/mergin/sync/storages/disk.py +++ b/server/mergin/sync/storages/disk.py @@ -98,10 +98,9 @@ def move_to_tmp(src, dest=None): if not os.path.exists(src): return dest = dest if dest else str(uuid.uuid4()) - rel_path = os.path.relpath( - src, start=current_app.config["LOCAL_PROJECTS"] - ) # take relative path from parent of all project files - temp_path = os.path.join(current_app.config["TEMP_DIR"], dest, rel_path) + temp_path = os.path.join( + current_app.config["TEMP_DIR"], dest, os.path.basename(src) + ) os.renames(src, temp_path) return temp_path diff --git a/server/mergin/tests/test_celery.py b/server/mergin/tests/test_celery.py index 44c36f2a..cc88e2d3 100644 --- a/server/mergin/tests/test_celery.py +++ b/server/mergin/tests/test_celery.py @@ -96,7 +96,7 @@ def test_clean_temp_files(app): assert os.path.exists(path) # patch modification time of parent dir t = datetime.utcnow() - timedelta(days=(app.config["TEMP_EXPIRATION"] + 1)) - parent_dir = os.path.dirname(os.path.dirname(path)) + parent_dir = os.path.dirname(path) os.utime(parent_dir, (datetime.timestamp(t), datetime.timestamp(t))) remove_temp_files() assert not os.path.exists(path) From 9bd4e7aea5ac50785c42d9207aaa6c7b2806f0fc Mon Sep 17 00:00:00 2001 From: Martin Varga Date: Thu, 26 Sep 2024 12:15:56 +0200 Subject: [PATCH 2/2] Add default geodiff working dir more reasonable --- server/mergin/sync/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/mergin/sync/config.py b/server/mergin/sync/config.py index de6edcfd..0f19deb4 100644 --- a/server/mergin/sync/config.py +++ b/server/mergin/sync/config.py @@ -50,5 +50,5 @@ class Configuration(object): # working directory for geodiff actions - should be a fast local storage GEODIFF_WORKING_DIR = config( "GEODIFF_WORKING_DIR", - default=os.path.join(LOCAL_PROJECTS, os.pardir, "geodiff_tmp"), + default=os.path.join(LOCAL_PROJECTS, "geodiff_tmp"), )