From 8f4eb870bb2e5862e221c26c3bef6673b3b145cc Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sun, 10 Oct 2021 21:12:52 +1100 Subject: [PATCH] use stat_mtime for gen hash (as moving a file does not change content) AND for fall-back date/time of importing a photo -- Fixes BUG-72 --- BUGs | 2 -- pa_job_manager.py | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/BUGs b/BUGs index eaa6d62..4d860bf 100644 --- a/BUGs +++ b/BUGs @@ -6,5 +6,3 @@ BUG-61: in Fullscreen mode and next/prev dropped out of FS when calling /viewlis -- then we can stay on-page, and stay in FS and then just call ViewImageOrVide() BUG-69: when moving a directory (maybe files???) it creates new destination directory even if one exists... not sure what the os.replace, etc. does at that point??? BUG-70: when a dir is a match and a file is a match (common with our date-based matching), then we get 2 answers in the search -BUG-72: when re-scanning import dir, I always regen hash for 20201225_181843.jpg - why? - -- also happened for a lot of storage photos, see job: 909 diff --git a/pa_job_manager.py b/pa_job_manager.py index 3ec4c60..b311737 100644 --- a/pa_job_manager.py +++ b/pa_job_manager.py @@ -1128,7 +1128,7 @@ def GetDateFromFile(file, stat): check2 = datetime( year, month, day ) # give up and use file sys date except: - year, month, day, _, _, _, _, _, _ = datetime.fromtimestamp(stat.st_ctime).timetuple() + year, month, day, _, _, _, _, _, _ = datetime.fromtimestamp(stat.st_mtime).timetuple() c=date(year, month, day).isocalendar() woy=c[1] return year, month, day, woy @@ -1349,7 +1349,7 @@ def GenHashAndThumb(job, e): if job.current_file_num % 100 == 0: session.commit() stat = os.stat( e.FullPathOnFS() ) - if stat.st_ctime < e.file_details.last_hash_date: + if stat.st_mtime < e.file_details.last_hash_date: if DEBUG: print(f"OPTIM: GenHashAndThumb {e.name} file is older than last hash, skip this") job.current_file_num+=1