diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-01-06 19:36:58 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-01-06 19:36:58 +0100 |
commit | 440a9d6874f8f6e26c12d9faf8b5bd96a98e8b35 (patch) | |
tree | 046c4521874bad55603045ce2a6878b9495162d9 /bin/hashl | |
parent | 9abe5f5065928887d7ba1d286c4e52da8178f6a6 (diff) |
Add 'hashl find-known'
Diffstat (limited to 'bin/hashl')
-rwxr-xr-x | bin/hashl | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -140,6 +140,15 @@ sub db_find_new { } } +sub db_find_known { + my ($file, $path) = @_; + my $in_db = file_in_db($path); + + if (defined $in_db) { + say "\r\e[2K${file}"; + } +} + sub db_info { printf( "Read size: %d bytes (%.f KiB)\n", @@ -271,6 +280,23 @@ sub cmd_copy { print "\n"; } +sub cmd_find_known { + my ($dir) = @_; + + $dir //= $base; + + if (substr($dir, 0, 1) ne '/') { + $dir = $base . '/' . $dir; + } + + prepare_db_run($dir); + + $find_ref = \&db_find_known; + $find_db_write = 0; + find(\&process_file, $dir); + print "\n"; +} + sub cmd_find_new { my ($new_dir) = @_; @@ -349,6 +375,7 @@ sub cmd_update { given ($action) { when ('copy') { cmd_copy(@ARGV) } + when ('find-known') { cmd_find_known(@ARGV) } when ('find-new') { cmd_find_new(@ARGV) } when ('ignore') { cmd_ignore(@ARGV) } when ('info') { cmd_info(@ARGV) } |