From 52ad4d2b4e2929327cde4ebd5c7fecec31c97344 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 18 Dec 2010 19:44:35 +0100 Subject: Use SHA1, print status --- bin/hashl | 15 +++++++++++---- 1 file 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); -- cgit v1.2.3