Skip to content

Fix timestamp when looking at photos#3571

Open
tintou wants to merge 3 commits into
nextcloud:masterfrom
tintou:tintou/timestamp-issue
Open

Fix timestamp when looking at photos#3571
tintou wants to merge 3 commits into
nextcloud:masterfrom
tintou:tintou/timestamp-issue

Conversation

@tintou

@tintou tintou commented Jun 21, 2026

Copy link
Copy Markdown

Reject timestamp 0 as it is very unlikely to represent the right time and least to photos being unsorted.

This is especially true for my setup using the S3 from OVH that seem to not return the mtime.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Fixes: #2768

tintou added 3 commits June 21, 2026 16:13
A camera with a reset clock can produce DateTimeOriginal '1970:01:01 00:00:00',
which parses successfully but yields timestamp 0. Storing 0 sorts the file to
the bottom of the DAV SEARCH DESC results, making it unreachable via pagination.

Fixes: nextcloud#2768
Assisted-by: claude:claude-sonnet-4-6
Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
… storage

The isLocal() guard was copied from ExifMetadataProvider, which reads file bytes.
This provider only uses filename and mtime from the local file cache, so deferring
to a background job left original_date_time as NULL for remote storage until the
job ran, causing photos to be invisible or misplaced in the timeline.

Fixes: nextcloud#2768
Assisted-by: claude:claude-sonnet-4-6
Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
Non-standard S3-compatible backends may return 0 for Last-Modified.
Storing 0 breaks sorting; leaving the metadata unset (NULL) is safer.

Fixes: nextcloud#2768
Assisted-by: claude:claude-sonnet-4-6
Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
@tintou tintou force-pushed the tintou/timestamp-issue branch from a492882 to d1f68f6 Compare June 21, 2026 14:13
Comment on lines -70 to -76
// We need the file content to extract the EXIF data.
// This can be slow for remote storage, so we do it in a background job.
if (!$node->getStorage()->isLocal() && $event instanceof MetadataLiveEvent) {
$event->requestBackgroundJob();
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure I understand the rationale.
The code below reads exif metadata, that does access the file bytes, so the guard was correct and the commit comment is wrong?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not reading the exif but getting the cached exif here (from what I understand from the code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New photos or videos not displayed in "All Media"; new Photos not displayed in "Photos"; new videos ARE displayed in "Videos"

2 participants