fix --mirror option to create directories and return nicer reports
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 18 May 2009 18:47:22 +0000 (18:47 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 18 May 2009 18:47:22 +0000 (18:47 +0000)
git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1183 07558da8-63fa-0310-ba24-9fe276d99e06

run.pl

diff --git a/run.pl b/run.pl
index 8b3d666..933cd06 100755 (executable)
--- a/run.pl
+++ b/run.pl
@@ -11,7 +11,7 @@ use WebPAC::Parser 0.08;
 use WebPAC::Input 0.16;
 use WebPAC::Store 0.15;
 use WebPAC::Normalize 0.22;
-use WebPAC::Output::TT;
+#use WebPAC::Output::TT;
 use WebPAC::Validate 0.11;
 use WebPAC::Output::MARC;
 use WebPAC::Config;
@@ -412,10 +412,18 @@ foreach my $database ( sort keys %{ $config->databases } ) {
 
                if ( $mirror ) {
                        my $path = $input->{path} || die "no input path in ",dump( $input );
-                       $log->info( "mirror ", $path, " ", -s $path, " bytes" );
 
-                       $log->warn( "$path not modified" )
-                               if mirror( "$mirror/$path", $path ) == RC_NOT_MODIFIED;
+                       my $base = $path;
+                       $base =~ s{/[^/]+$}{};
+                       mkpath $base unless -e $base;
+
+                       my $rc = mirror( "$mirror/$path", $path );
+                       if (is_error( $rc )) {
+                               die "can't mirror $mirror/$path -> $path [$rc]";
+                       } else {
+                               $log->info( "mirror ", $path, " [$rc] ", -s $path, " bytes" );
+                       }
+                       
                }
 
                my $input_db = new WebPAC::Input(