From ef33ea24e3e472d8098bd490043e5c0f53d9374c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 19 Aug 2012 12:12:30 +0200 Subject: move db_info into Hashl.pm --- bin/hashl | 18 +++++------------- lib/App/Hashl.pm | 9 +++++++++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/bin/hashl b/bin/hashl index 1d53691..d3187c5 100755 --- a/bin/hashl +++ b/bin/hashl @@ -21,6 +21,7 @@ my $db_file = '.hashl.db'; my $total = 0; my $cur = 0; my $show_progress = 1; +my @edb_files; my $timer; my $incoming_dir; my $read_size; @@ -34,6 +35,7 @@ STDERR->autoflush(1); GetOptions( 'd|database=s' => \$db_file, + 'e|extra-db=s' => \@edb_files, 'f|force' => \$add_unignore, 'n|no-progress' => sub { $show_progress = 0 }, 's|read-size=i' => sub { $read_size = $_[1] * 1024 }, @@ -83,7 +85,7 @@ sub get_total { } sub drop_deleted { - for my $file ( $hashl->files() ) { + for my $file ( $hashl->files ) { if ( not -e $file ) { $hashl->delete_file($file); } @@ -126,16 +128,6 @@ sub db_find_known { return; } -sub db_info { - printf( "Database created by hashl v%s\n", $hashl->db_version, ); - printf( - "Read size: %d bytes (%s)\n", - $hashl->read_size, $hashl->si_size( $hashl->read_size ), - ); - - return; -} - sub file_info { my ($file) = @_; @@ -335,7 +327,7 @@ sub cmd_info { file_info($file); } else { - db_info(); + $hashl->db_info(); } return; @@ -549,7 +541,7 @@ C<< cd /tmp/mnt/ext; hashl copy /media/videos/incoming >> Personally, I have all my videos on an external hard disk, which I usually do not carry with me. So, when I get new videos, I put them into F<~/lib/videos> -on my netboo, and then later copy them to the external disk. Of course, it +on my netbook, and then later copy them to the external disk. Of course, it can always happen that I get a movie I already have, or forget to move something from F<~/lib/videos> to the external disk, especially since I also always have some stuff from the disk in F<~/lib/videos>. diff --git a/lib/App/Hashl.pm b/lib/App/Hashl.pm index dc5fca5..f17f771 100644 --- a/lib/App/Hashl.pm +++ b/lib/App/Hashl.pm @@ -107,6 +107,15 @@ sub read_size { return $self->{config}->{read_size}; } +sub db_info { + my ($self) = @_; + + return sprintf( + "Database created by hashl v%s\n" . "Read size: %d bytes (%s)\n", + $self->db_version, $self->read_size, $self->si_size( $self->read_size ), + ); +} + sub db_version { my ($self) = @_; -- cgit v1.2.3