]> mj.ucw.cz Git - gallery.git/commitdiff
Gallery2: Let gal gen remove stale files
authorMartin Mares <mj@ucw.cz>
Thu, 27 Dec 2012 22:16:25 +0000 (23:16 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 8 Feb 2015 20:14:15 +0000 (21:14 +0100)
gal2/bin/gal-gen

index 6c767d83bec756f67d5c3119435c6fd6cc5314cb..94c291b5da8a198ef5106f067bdfaca413d445d6 100755 (executable)
@@ -119,5 +119,15 @@ for my $f (@$orig_list) {
        print "... OK\n";
 }
 
+print "Cleaning up stale files\n";
+for my $f (<$photo_dir/*.jpg>) {
+       my ($vv, $dd, $id) = File::Spec->splitpath($f);
+       $id =~ s{\..*$}{};
+       unless (defined $meta->{photo}->{$id}) {
+               print "$id: removing\n";
+               unlink $f;
+       }
+}
+
 print "Writing meta-data\n";
 $gal->write_meta($photo_meta, $meta);