Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebDAV: Preserve file modification timestamps #3959

Closed
graciousgrey opened this issue Dec 18, 2023 Discussed in #2550 · 6 comments
Closed

WebDAV: Preserve file modification timestamps #3959

graciousgrey opened this issue Dec 18, 2023 Discussed in #2550 · 6 comments
Assignees
Labels
enhancement Optimization, improvement or maintenance task metadata Related to Exif, XMP, IPTC & Co. tested Changes have been tested successfully

Comments

@graciousgrey
Copy link
Member

As a user I want the built in webdavserver to preserve timestamps, so that the file modification date is not changed when files get synced using webdav.

Acceptance Criteria:

Discussed in #2550

Originally posted by atvking July 26, 2022
I'm running PhotoPrism in a docker container on an UnRaid server and it doesn't seem to matter what client I use (FolderSync Pro, PhotoSync, Windows File Explorer, etc.) to upload to the Originals folder, the modification date of the file is always changed to the date/time of upload rather than the date/time the photo was taken. Is there some way to avoid this?

Uploading the same files using the same clients to a folder in Nextcloud via its WebDAV server doesn't have the same issue.

I'm trying to avoid uploading to a Nextcloud folder via Nextclouds WebDAV and setting my Originals folder to use that folder because then I would have to schedule a cron job (or something) to index the files, whereas they are indexed automatically when using Photoprisms WebDAV.

I have already tried setting the PHOTOPRISM_DISABLE_CHOWN flag but I didn't have much hope that it would work anyway because the folder ownership and permissions are identical between the Originals folder on my PhotoPrism share and the Nextcloud folder I am syncing the same files to (as a test) on my Nextcloud share and do not change after uploading a file.

Suggestions?

@graciousgrey graciousgrey added the enhancement Optimization, improvement or maintenance task label Dec 18, 2023
lastzero added a commit that referenced this issue Jan 8, 2024
Note that this is still experimental and the implementation needs to be
tested with a WebDAV client that sends a valid "X-OC-MTime" header.

Signed-off-by: Michael Mayer <michael@photoprism.app>
@lastzero lastzero self-assigned this Jan 8, 2024
@lastzero lastzero added the please-test Ready for acceptance test label Jan 8, 2024
lastzero added a commit that referenced this issue Jan 9, 2024
Signed-off-by: Michael Mayer <michael@photoprism.app>
lastzero added a commit that referenced this issue Jan 10, 2024
Signed-off-by: Michael Mayer <michael@photoprism.app>
@lastzero
Copy link
Member

lastzero commented Jan 31, 2024

The photoprism/photoprism:test image available on Docker Hub includes support for setting the mtime based on the X-OC-MTime header:

Note that this is a custom, non-standard header and therefore only works when WebDAV clients like PhotoSync submit this header along with the uploaded file. We would therefore appreciate if you could help us test these changes and provide feedback on them (by using the test image) before we make them available to everyone in the upcoming release.

Edit: If the WebDAV client/app you are using does not submit the file modification date, there is not much we can do. However, it should be easy for app developers to add it if you ask them to. Thank you!

@lastzero lastzero added the help wanted Well suited for external contributors! label Jan 31, 2024
@jtamm-red
Copy link

@lastzero Please build arm64 image!

I tried to pull test version and deploy docker, got error:

photoprism The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 

@graciousgrey
Copy link
Member Author

First tests showed that the modification date could not be preserved when syncing using PhotoSync or Apples finder. There may be special settings needed or they do not support the header.

@lastzero
Copy link
Member

Since the time we can spend on this is quite limited due to the many other issues that also need attention, we would appreciate help with testing and finding out which WebDAV clients support this or another timestamp request header. Thank you very much! 🙏

@dominikholler
Copy link

Since the time we can spend on this is quite limited due to the many other issues that also need attention, we would appreciate help with testing and finding out which WebDAV clients support this or another timestamp request header. Thank you very much! 🙏

Thanks for adding the timestamp support! This is not only useful during import, but also when the originals are managed via webdav. rclone serve had recently a similar improvement in rclone/rclone#6990 .

Rclone is able to set the file timestamp in the current photoprism test version.

Verified by

  1. Run photoprism
podman run -it --rm  -p 2342:2342 -e PHOTOPRISM_ADMIN_PASSWORD=123456  -e PHOTOPRISM_SITE_URL=http://t470:2342/  docker.io/photoprism/photoprism:test
  1. Add photoprim originals as nextcloud to rclone.conf, password is stored obscured
[photoprism]
type = webdav
url = http://t470:2342/originals
vendor = nextcloud
user = admin
pass = E8_3ZUw0zNR4E4Tv_QOEBsSLH4StRQ
  1. upload photo
user@t470:~/Pictures/landscape/2023$ ls -l IMG_20231008_172853.jpg
-rw-rw-r-- 1 user user 4784742 Oct  8 17:28 IMG_20231008_172853.jpg
user@t470:~/Pictures/landscape/2023$ rclone copy IMG_20231008_172853.jpg photoprism:/
  1. check if photoprim applied the timestamp
user@t470:~/Pictures/landscape/2023$ rclone lsl photoprism:/IMG_20231008_172853.jpg
  4784742 2023-10-08 17:28:53.000000000 IMG_20231008_172853.jpg
user@t470:~/Pictures/landscape/2023$ rclone mount photoprism:/ /tmp/p &
[1] 41192
user@t470:~/Pictures/landscape/2023$ 2024/02/18 16:44:21 NOTICE: webdav root '': --vfs-cache-mode writes or full is recommended for this remote as it can't stream

user@t470:~/Pictures/landscape/2023$ ls -l /tmp/p
total 4673
-rw-rw-r-- 1 user user 4784742 Oct  8 17:28 IMG_20231008_172853.jpg
user@t470:~/Pictures/landscape/2023$ fusermount -u /tmp/p

@dominikholler
Copy link

dominikholler commented Feb 18, 2024

FolderSync is able to set the file timestamp in the current photoprism test version.

Verified by:

  1. Run photoprism
podman run -it --rm  -p 2342:2342 -e PHOTOPRISM_ADMIN_PASSWORD=123456  -e PHOTOPRISM_SITE_URL=https://192.168.178.27  docker.io/photoprism/photoprism:test
  1. Use caddy as a reverse proxy, to enable https and logging
./caddy_linux_amd64 reverse-proxy --access-log --from 192.168.178.27:443 --to http://localhost:2342
  1. Sync photo folder on android phone to plain WebDAV (not NextCloud)
Server Address: 192.168.178.27
Path: import
  1. Check Caddy logs for X-Oc-Mtime
2024/02/18 17:52:22.767	INFO	http.log.access	handled request	{"request": {"remote_ip": "192.168.178.63", "remote_port": "37546", "client_ip": "192.168.178.63", "proto": "HTTP/2.0", "method": "PUT", "host": "192.168.178.27", "uri": "/import/IMG_20240212_112603.jpg", "headers": {"Translate": ["f"], "Pragma": ["no-cache"], "Cache-Control": ["no-cache"], "X-Oc-Mtime": ["1707733564"], "Content-Length": ["3139891"], "Accept-Encoding": ["gzip"], "User-Agent": ["OkHttp"], "Http.protocol.expect-Continue": ["true"], "Authorization": [], "Content-Type": ["image/jpeg"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "server_name": ""}}, "bytes_read": 3139891, "user_id": "", "duration": 0.640371993, "size": 7, "status": 201, "resp_headers": {"Content-Type": ["text/plain; charset=utf-8"], "Server": ["Caddy"], "Alt-Svc": ["h3=\":443\"; ma=2592000"], "Content-Security-Policy": ["frame-ancestors 'none';"], "Etag": ["\"17b506773783438e2fe933\""], "X-Frame-Options": ["DENY"], "Date": ["Sun, 18 Feb 2024 17:52:22 GMT"], "Content-Length": ["7"]}}
  1. Verify by rclone:
rclone.conf:
[photoprism]
type = webdav
url = http://t470:2342/import
vendor = nextcloud
user = admin
pass = E8_3ZUw0zNR4E4Tv_QOEBsSLH4StRQ

rclone lsl photoprism:/
  3139891 2024-02-12 11:26:04.000000000 IMG_20240212_112603.jpg

@lastzero lastzero added the metadata Related to Exif, XMP, IPTC & Co. label Mar 22, 2024
@graciousgrey graciousgrey added tested Changes have been tested successfully and removed please-test Ready for acceptance test help wanted Well suited for external contributors! labels Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Optimization, improvement or maintenance task metadata Related to Exif, XMP, IPTC & Co. tested Changes have been tested successfully
Projects
Status: Release 🌈
Development

No branches or pull requests

4 participants