Commit 43910e3a authored by Mike Hibler's avatar Mike Hibler
Browse files

For the fixit option (-F), if the DB hash is null, rehash it and record.

parent 4834bd06
......@@ -247,12 +247,6 @@ sub doimage($)
$stamp = 0
if (!defined($stamp));
if ($fixit) {
print "$pidimage: fixing hash file\n";
makehashfile($path, $hash);
return 0;
}
if ($showinfo) {
print "$pidimage: path: $path\n";
print "$pidimage: mtime: $stamp\n";
......@@ -290,6 +284,30 @@ sub doimage($)
return 1;
}
if ($fixit) {
print "$pidimage: fixing hash file\n";
if ($hash eq "") {
$hash = `$SHA1 $path`;
if ($?) {
print("$pidimage: hash: could not generate SHA1 hash of '$path'\n");
return 1;
} else {
if ($hash =~ /^SHA1.*= ([\da-fA-F]+)$/) {
$hash = lc($1);
} else {
print("$pidimage: hash: could not parse sha1 hash: '$hash'\n");
return 1;
}
}
if ($image->SetHash($hash) != 0) {
print("$pidimage: hash: could not store new hash: '$hash'\n");
return 1;
}
}
makehashfile($path, $hash);
return 0;
}
my $rv = 0;
my $changed = 0;
......
Markdown is supported
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