Skip to content

WebDAV upload does not preserve file modification times #376

@phernandez

Description

@phernandez

Problem

When uploading files via , the file modification times are not preserved. Files get new modification times set to the upload time instead of keeping their original timestamps. This causes issues with:

  1. Sync accuracy: The sync system relies on filesystem timestamps (per fix: Use filesystem timestamps for entity sync instead of database operation time (#138) #369) to detect changes
  2. Historical context: Users lose the temporal context of when notes were actually created/modified
  3. False sync triggers: Files with changed timestamps may trigger unnecessary syncs

Current Behavior

Client side (src/basic_memory/cli/commands/cloud/upload.py:86-91):

  • Reads file content and sends via HTTP PUT
  • Does not include original modification time in request

Server side (apps/api/src/basic_memory_cloud_api/webdav.py:203-248):

  • Writes file content without preserving modification times
  • Files get current timestamp

Expected Behavior

Files uploaded via WebDAV should retain their original modification times.

Solution

Implement modification time preservation in both client and server:

  1. Client: Read file's st_mtime and send as HTTP header (e.g., X-OC-Mtime or Win32LastModifiedTime)
  2. Server: Read modification time header and use os.utime() to set it after writing file

Affected Components

  • basic-memory: CLI upload command (client side)
  • basic-memory-cloud: WebDAV server (server side)

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcloudBasic Memory CloudenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions