summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2010-12-18 19:44:35 +0100
committerDaniel Friesel <derf@finalrewind.org>2010-12-18 19:44:35 +0100
commit52ad4d2b4e2929327cde4ebd5c7fecec31c97344 (patch)
treef6922b6132d5507c260eb5b2523db1399be824be
parenta83edab6e3044a967496eea1bc5e6207f6bf890a (diff)
Use SHA1, print status
-rwxr-xr-xbin/hashl15
1 files changed, 11 insertions, 4 deletions
diff --git a/bin/hashl b/bin/hashl
index a89bbee..eaa2cc9 100755
--- a/bin/hashl
+++ b/bin/hashl
@@ -8,7 +8,7 @@ use 5.010;
use autodie;
use Cwd;
-use Digest::MD5 qw(md5_hex);
+use Digest::SHA qw(sha1_hex);
use File::Find;
use Storable qw(nstore retrieve);
@@ -22,6 +22,13 @@ if (-r 'hashl.db') {
$db = retrieve('hashl.db');
}
+sub print_status {
+ my ($file) = @_;
+ local $| = 1;
+
+ print "\r\e[2K${file}";
+}
+
sub process_file {
my $file = $File::Find::name;
my $path = $file;
@@ -36,6 +43,8 @@ sub process_file {
$file = substr($file, length($base) + 1);
}
+ print_status($file);
+
if (exists($db->{$file}) and
$db->{$file}->{'mtime'} == $mtime and
$db->{$file}->{'size'} == $size ) {
@@ -48,12 +57,10 @@ sub process_file {
close($fh);
$db->{$file} = {
- hash => md5_hex($data),
+ hash => sha1_hex($data),
mtime => $mtime,
size => $size,
};
-
- printf("%s %s\n", $db->{$file}->{'hash'}, $file);
}
find(\&process_file, $base);