From 04ab1adad34e69c5ef44884c5d85d366623eb90b Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 2 Jan 2011 00:22:06 +0100 Subject: Add hashl find-new --- bin/hashl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/bin/hashl b/bin/hashl index b17e506..af070a9 100755 --- a/bin/hashl +++ b/bin/hashl @@ -130,6 +130,14 @@ sub file_in_db { return hash_in_db(hash_file($file)); } +sub db_find_new { + my ($file, $path) = @_; + + if (not defined file_in_db($path)) { + say "\r\e[2K${file}"; + } +} + sub db_info { printf( "Read size: %d bytes (%.f KiB)\n", @@ -249,6 +257,23 @@ sub cmd_copy { print "\n"; } +sub cmd_find_new { + my ($new_dir) = @_; + + $new_dir //= $base; + + prepare_db_run(); + + if (substr($new_dir, 0, 1) ne '/') { + $new_dir = $base . '/' . $new_dir; + } + + $find_ref = \&db_find_new; + $find_db_write = 0; + find(\&process_file, $new_dir); + print "\n"; +} + sub cmd_ignore { my ($ign_dir) = @_; @@ -304,6 +329,7 @@ sub cmd_update { given ($action) { when ('copy') { cmd_copy(@ARGV) } + when ('find-new') { cmd_find_new(@ARGV) } when ('ignore') { cmd_ignore(@ARGV) } when ('info') { cmd_info(@ARGV) } when ('list') { cmd_list(@ARGV) } -- cgit v1.2.3