From e6c8e3662c853399aee1f7a9c4e921431dbc5cdb Mon Sep 17 00:00:00 2001 From: Paul Hernandez <60959+phernandez@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:18:10 -0500 Subject: [PATCH] fix: preserve mtime webdav upload 376 (#377) Signed-off-by: Claude Signed-off-by: phernandez Co-authored-by: Claude --- src/basic_memory/cli/commands/cloud/upload.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/basic_memory/cli/commands/cloud/upload.py b/src/basic_memory/cli/commands/cloud/upload.py index 5add0a78..deb71673 100644 --- a/src/basic_memory/cli/commands/cloud/upload.py +++ b/src/basic_memory/cli/commands/cloud/upload.py @@ -82,12 +82,19 @@ async def upload_path( remote_path = f"/webdav/{project_name}/{relative_path}" print(f"Uploading {relative_path} ({i}/{len(files_to_upload)})") + # Get file modification time + file_stat = file_path.stat() + mtime = int(file_stat.st_mtime) + # Read file content asynchronously async with aiofiles.open(file_path, "rb") as f: content = await f.read() - # Upload via HTTP PUT to WebDAV endpoint - response = await call_put(client, remote_path, content=content) + # Upload via HTTP PUT to WebDAV endpoint with mtime header + # Using X-OC-Mtime (ownCloud/Nextcloud standard) + response = await call_put( + client, remote_path, content=content, headers={"X-OC-Mtime": str(mtime)} + ) response.raise_for_status() # Format total size based on magnitude