summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-01-02 00:22:06 +0100
committerDaniel Friesel <derf@finalrewind.org>2011-01-02 00:22:06 +0100
commit04ab1adad34e69c5ef44884c5d85d366623eb90b (patch)
tree46d7c3ac9c231f41abd4e30809e27d7620ca7952
parentaba7f5c394b8d5fd8e9359141cc7706ba303208c (diff)
Add hashl find-new
-rwxr-xr-xbin/hashl26
1 files changed, 26 insertions, 0 deletions
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) }