From eba54dbce3e8410bc2e9da69e7e4a26251573f87 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 18 Jul 2026 16:50:03 +0300 Subject: Fix CHRONOLOGICAL_ORDER to reject camera clock-reset EXIF dates A real album (irregular.ninja/so.war.das) surfaced the bug: a Fujifilm X100V whose battery died reset its clock to 2000-01-01, and every EXIF timestamp on that roll was stamped with the bogus date instead of being omitted. Trusting it at face value sorted that whole roll to the front of the album, ahead of hundreds of correctly-dated 2020s photos. EXIF years before 2001 are now treated the same as a missing date tag. The no-date fallback also switches from source mtime to filename order, since mtime is not reliable either -- bulk-copying/rsyncing an incoming directory commonly rewrites every file's mtime to the transfer time, unrelated to capture order -- while sequential camera filenames track real shooting order even across a clock reset. Co-Authored-By: Claude Sonnet 5 --- README.md | 7 +-- bin/shuriken | 55 ++++++++++++-------- docs/configuration.md | 19 ++++--- docs/generation.md | 2 +- src/lib/album-photo-select.source.sh | 55 ++++++++++++-------- tests/cli.sh | 98 ++++++++++++++++++++++++++++-------- 6 files changed, 162 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index c8c71b6..d12c0ee 100644 --- a/README.md +++ b/README.md @@ -123,9 +123,10 @@ Feature toggles at a glance: repeatable. * **Chronological order** (`CHRONOLOGICAL_ORDER=no`, the default): set to `yes` (or pass `--chronological`) to order the main album's photos by EXIF - date taken instead of filename/shuffle order, falling back to source mtime - for photos with no usable EXIF date. Takes precedence over `SHUFFLE` when - both are enabled. + date taken instead of filename/shuffle order (years before 2001 are + treated as an implausible camera clock-reset default, not a real date), + falling back to filename order for photos with no usable EXIF date. Takes + precedence over `SHUFFLE` when both are enabled. ## Documentation diff --git a/bin/shuriken b/bin/shuriken index fd7eda1..627de13 100755 --- a/bin/shuriken +++ b/bin/shuriken @@ -3540,7 +3540,8 @@ build_preview_thumbnail() { # Main album display order, in precedence order (task 8v0): # 1. CHRONOLOGICAL_ORDER=yes -> chronological_photo_files (EXIF date taken, -# ascending, falling back to mtime for photos without one). +# ascending, falling back to filename order for photos without a usable +# one). # 2. otherwise -> the historical maybe_shuffle path (seeded/random SHUFFLE, or # plain filename sort when SHUFFLE=no). # CHRONOLOGICAL_ORDER therefore takes precedence over SHUFFLE when both are @@ -3564,6 +3565,16 @@ album_photo_files() { | maybe_shuffle } +# Digital cameras were not commercially available before the 1990s, and a +# long tail of camera bodies -- including the Fujifilm X100V that motivated +# this constant -- silently default their clock to "2000-01-01" (or similar) +# once its battery dies, then stamp every EXIF timestamp with that bogus date +# instead of omitting it. An EXIF year below this is therefore treated as +# unusable rather than real, so a whole clock-reset camera roll does not sort +# to the very front of an otherwise correctly-dated album (see +# chronological_sort_key_for_photo). +readonly CHRONOLOGICAL_MIN_PLAUSIBLE_YEAR=2001 + # Build the sort key chronological_photo_files uses to order one photo: a # tab-separated "\t