Commit 22c3e7ed authored by Mike Hibler's avatar Mike Hibler
Browse files

Create .sha1 file in the same format as before!

Also, add undocumented -F option to quickly fix any broken hash files
(i.e., by reading hash value from the DB and not recomputing it).
parent 5db4bc14
...@@ -59,7 +59,7 @@ sub usage() ...@@ -59,7 +59,7 @@ sub usage()
" default is 'all'\n"); " default is 'all'\n");
exit(-1); exit(-1);
} }
my $optlist = "dfnupqRaP:UH:V:"; my $optlist = "dfnupqRaP:UH:V:F";
my $debug = 0; my $debug = 0;
my $showinfo = 0; my $showinfo = 0;
my $update = 0; my $update = 0;
...@@ -165,6 +165,11 @@ if (defined($options{"V"})) { ...@@ -165,6 +165,11 @@ if (defined($options{"V"})) {
} }
@images = @ARGV; @images = @ARGV;
my $fixit = 0;
if (defined($options{"F"})) {
$fixit = 1;
}
my ($user,$user_uid); my ($user,$user_uid);
if ($UID) { if ($UID) {
$user = User->ThisUser(); $user = User->ThisUser();
...@@ -242,6 +247,12 @@ sub doimage($) ...@@ -242,6 +247,12 @@ sub doimage($)
$stamp = 0 $stamp = 0
if (!defined($stamp)); if (!defined($stamp));
if ($fixit) {
print "$pidimage: fixing hash file\n";
makehashfile($path, $hash);
return 0;
}
if ($showinfo) { if ($showinfo) {
print "$pidimage: path: $path\n"; print "$pidimage: path: $path\n";
print "$pidimage: mtime: $stamp\n"; print "$pidimage: mtime: $stamp\n";
...@@ -486,7 +497,8 @@ sub makehashfile($$) ...@@ -486,7 +497,8 @@ sub makehashfile($$)
unlink($hashfile); unlink($hashfile);
if (open(HASH, ">$hashfile")) { if (open(HASH, ">$hashfile")) {
print HASH $hash; # XXX recreate the sha1 output format for compatibility
print HASH "SHA1 ($imagepath) = $hash\n";
close($hashfile); close($hashfile);
system("touch -r $imagepath $hashfile"); system("touch -r $imagepath $hashfile");
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment