summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2012-08-19 12:43:17 +0200
committerDaniel Friesel <derf@finalrewind.org>2012-08-19 12:43:17 +0200
commita6d571bed52b7a6a66ea21ce8dbe38dbe382e8f5 (patch)
tree89ed37df2195aef10bc43f11d3e0664edb49dfe8
parentef33ea24e3e472d8098bd490043e5c0f53d9374c (diff)
find-new / find-known: Support multiple database files
-rwxr-xr-xbin/hashl25
1 files changed, 21 insertions, 4 deletions
diff --git a/bin/hashl b/bin/hashl
index d3187c5..2ec73b9 100755
--- a/bin/hashl
+++ b/bin/hashl
@@ -12,6 +12,7 @@ use File::Copy;
use File::Find;
use Getopt::Long;
use IO::Handle;
+use List::MoreUtils qw(any);
use Time::Progress;
my $add_unignore = 0;
@@ -28,6 +29,7 @@ my $read_size;
my ( $find_ref, $find_db_write );
my $hashl;
+my @ehashl;
our $VERSION = '1.00';
@@ -65,6 +67,16 @@ if ( -r $db_file ) {
else {
$hashl = App::Hashl->new( read_size => $read_size );
}
+@ehashl = ($hashl);
+
+for my $file (@edb_files) {
+ if (-r $file) {
+ push(@ehashl, App::Hashl->new_from_file($file));
+ }
+ else {
+ die("-e ${file}: database does not exist\n");
+ }
+}
local $SIG{INT} = \&quit_save_db;
local $SIG{TERM} = \&quit_save_db;
@@ -111,7 +123,7 @@ sub copy_file {
sub db_find_new {
my ( $file, $path ) = @_;
- if ( not $hashl->file_in_db($path) ) {
+ if ( not any { $_->file_in_db($path) } @ehashl ) {
say "\r\e[2K${file}";
}
@@ -121,7 +133,7 @@ sub db_find_new {
sub db_find_known {
my ( $file, $path ) = @_;
- if ( $hashl->file_in_db($path) ) {
+ if ( any { $_->file_in_db($path) } @ehashl ) {
say "\r\e[2K${file}";
}
@@ -425,12 +437,12 @@ I<newdir>.
=item B<find-known> [I<directory>]
-List all files which are already in the database. Scans either the current
+List all files which are already in any database. Scans either the current
directory or I<directory>.
=item B<find-new> [I<directory>]
-List all files which are not in the database. Scans either the current
+List all files which are not in any database. Scans either the current
directory or I<directory>.
=item B<ignore> [I<directory>]
@@ -473,6 +485,11 @@ directory.
Use I<dbfile> instead of F<.hashl.db>
+=item B<-e>|B<--extra-db> I<dbfile>
+
+Use I<dbfile> in addition to F<.hashl.db> / B<-d>. May be specified
+several times. Does not affect all commands.
+
=item B<-f>|B<--force>
For use with C<< hashl add >>: If there are ignored files in the directory,