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

Upload: Preserve file modification timestamps #3942

Open
cttlee opened this issue Dec 8, 2023 · 7 comments
Open

Upload: Preserve file modification timestamps #3942

cttlee opened this issue Dec 8, 2023 · 7 comments
Labels
frontend Requires experience with HTML/JS/CSS help wanted Well suited for external contributors! idea Feedback wanted / feature request metadata Related to Exif, XMP, IPTC & Co.

Comments

@cttlee
Copy link

cttlee commented Dec 8, 2023

Describe what problem this solves and why this would be valuable to many users
Describe the solution you'd like

Photoprism didn't use mtime as timestamp when no related exif info
Use mtime as timestamp as like google photo when no related exif info
The same logic can be found on immich as well
immich-app/immich#4188

Describe alternatives you've considered

Updating by exiftool manually was difficult since files were tens of thousands, also some video formats were not supported by exiftool and some files did not have exif such as screenshot pictures.

Additional context

@cttlee cttlee added the idea Feedback wanted / feature request label Dec 8, 2023
@lastzero
Copy link
Member

lastzero commented Dec 8, 2023

See our User Guide FAQ at https://docs.photoprism.app/user-guide/faq/#metadata:

If there is no date information available in the metadata or the original file names, the file system modification time is used to sort pictures in search results and to create canonical file names for them during import. However, this is usually not the actual date a photo was taken (or a graphic was created by the original author), but only the time you downloaded or copied it. As a result, the date of pictures without a reliable creation date will be displayed as "Unknown" until you manually set a date in the edit dialog.

@cttlee
Copy link
Author

cttlee commented Dec 8, 2023

00000.zip

I uploaded one mts and one jpeg to photoprism demo,
mtime were 2011 and 2004, but both be shown at 2023/12
螢幕擷取畫面 2023-12-08 150419
螢幕擷取畫面 2023-12-08 151035

date on google photo
螢幕擷取畫面 2023-12-08 151840

@lastzero
Copy link
Member

lastzero commented Dec 8, 2023

@cttlee So the feature request would be to preserve the local file system timestamps when using the web upload (which effectively creates new files on the server)?

I suppose the local time could be read through the JS File API and then transferred along with the files to preserve the time e.g. similar to this:

Screenshot 2023-12-08 at 08 19 54
Source: https://github.com/flohall/files_upload_mtime/blob/master/js/upload_mtime.js

If someone extends the frontend as needed and sends a pull request, I'd be happy to add support for preserving timestamps on the server side:

A suitable request header name for adding the information could be X-Last-Modified, ideally in some standard format e.g. as a unix timestamp or ISO date.

On the server, the code might look similar to how the "favorite" flag is preserved when uploading via WebDAV:

if r.Method == MethodPut && r.Header.Get("X-Favorite") == "1" {
if router.BasePath() == conf.BaseUri(WebDAVOriginals) {
MarkUploadAsFavorite(filepath.Join(conf.OriginalsPath(), strings.TrimPrefix(r.URL.Path, router.BasePath())))
} else if router.BasePath() == conf.BaseUri(WebDAVImport) {
MarkUploadAsFavorite(filepath.Join(conf.ImportPath(), strings.TrimPrefix(r.URL.Path, router.BasePath())))
}
}

@lastzero lastzero changed the title metadata: Use mtime as timestamp when no relates exif info Web Upload: Preserve File Modification Timestamps Dec 8, 2023
@lastzero lastzero added help wanted Well suited for external contributors! frontend Requires experience with HTML/JS/CSS metadata Related to Exif, XMP, IPTC & Co. labels Dec 8, 2023
@phpbg
Copy link

phpbg commented Dec 9, 2023

Hi, does your web upload uses webdav protocol? FYI nextcloud uses X-OC-MTime and X-OC-CTime headers.

See https://docs.nextcloud.com/server/latest/developer_manual/client_apis/WebDAV/basic.html#request-headers

@lastzero
Copy link
Member

lastzero commented Dec 9, 2023

We offer a WebDAV api you can use. See our documentation. The basic web upload does not use WebDAV though.

@phpbg
Copy link

phpbg commented Dec 9, 2023

OK, thanks for your info. I just saw the discussion for creation/modification timestamps over webdav happens here: #2550

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 changed the title Web Upload: Preserve File Modification Timestamps Upload: Preserve file modification timestamps Jan 8, 2024
@lastzero
Copy link
Member

lastzero commented Jan 8, 2024

@cttlee I just added an experimental implementation for setting the mtime based on the X-OC-MTime header. However, this only works with WebDAV and not with the regular file upload in the Web UI. It also requires using a WebDAV client that sends this custom header when uploading files:

Any help with testing will be much appreciated once an updated development preview is available. In the meantime, you can also test with the photoprism/photoprism:test image temporarily available on Docker Hub to test the other changes we are working on.

lastzero added a commit that referenced this issue Jan 10, 2024
Signed-off-by: Michael Mayer <michael@photoprism.app>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Requires experience with HTML/JS/CSS help wanted Well suited for external contributors! idea Feedback wanted / feature request metadata Related to Exif, XMP, IPTC & Co.
Projects
None yet
Development

No branches or pull requests

3 participants