diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/update.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/scripts/update.rb b/scripts/update.rb index 1a00ddf..5671330 100644 --- a/scripts/update.rb +++ b/scripts/update.rb @@ -51,15 +51,20 @@ def process_dir(dir, idx, total) label = rel.empty? ? '(root)' : rel prefix = "[#{idx}/#{total}]" + pending_faces = false unless FORCE_UPDATE sentinel = File.join(dir, SENTINEL_FILE) if File.exist?(sentinel) && File.mtime(sentinel) >= File.mtime(dir) - puts "#{prefix} Skipping #{label} (unchanged)" - return + if faces_pending?(dir) + pending_faces = true # fall through, but only to run face detection + else + puts "#{prefix} Skipping #{label} (unchanged)" + return + end end end - puts "#{prefix} Scanning #{label}" + puts "#{prefix} Scanning #{label}#{' (face detection pending)' if pending_faces}" json_path = File.join(dir, 'album.json') data = load_json(json_path) @@ -290,6 +295,16 @@ rescue JSON::ParserError => e {} end +def faces_pending?(dir) + return false unless FACES_ENABLED + json_path = File.join(dir, 'album.json') + return false unless File.exist?(json_path) + (load_json(json_path)['files'] || {}).any? do |name, meta| + IMAGE_EXTS.include?(File.extname(name).downcase.delete_prefix('.')) && + meta['faces'].nil? + end +end + # Fields the admin controls — never overwrite with stale values from our earlier read. ADMIN_ALBUM_KEYS = %w[title description cover cover_dynamic sort_reverse visible].freeze ADMIN_FILE_KEYS = %w[title caption visible].freeze |
