=================================================================== RCS file: /cvs/wpscripts/ztransfer/fetch.pm,v retrieving revision 1.1.1.1 retrieving revision 1.8 diff -u -r1.1.1.1 -r1.8 --- wpscripts/ztransfer/fetch.pm 2011/06/03 09:28:47 1.1.1.1 +++ wpscripts/ztransfer/fetch.pm 2012/04/01 06:52:10 1.8 @@ -1,14 +1,14 @@ #!/usr/bin/perl -# $Id: fetch.pm,v 1.1.1.1 2011/06/03 09:28:47 yason Exp $ +# $Id: fetch.pm,v 1.8 2012/04/01 06:52:10 yason Exp $ package fetch; use db; use log; # bad! only for log::filelist() use warnings; -my $EXPAND_SYMLINKS = 1; my $QUERY_Z = "SELECT ID,Path,file_priority FROM upload_files WHERE Status=0 AND type_file=0"; -my $QUERY_J = "SELECT ID,Path,file_priority FROM upload_files WHERE Status=0 AND type_file=1"; -my $QUERY_P = "SELECT ID,Path,file_priority FROM upload_files WHERE Status=0 AND type_file=2"; -my $QUERY_T = "SELECT ID,Path,file_priority FROM upload_files WHERE Status=0 AND type_file=3"; +my $QUERY_P = "SELECT ID,Path,file_priority FROM upload_files WHERE Status=0 AND type_file=1"; +my $QUERY_T = "SELECT ID,Path,file_priority FROM upload_files WHERE Status=0 AND type_file=2"; +my $QUERY_ZJ = "SELECT ID,Path,file_priority FROM upload_files WHERE Status=0 AND type_file=3"; +my $QUERY_PJ = "SELECT ID,Path,file_priority FROM upload_files WHERE Status=0 AND type_file=4"; my $sth; @@ -39,24 +39,18 @@ if($dbids[$i]) # element exists (THIS CODE SHOULD BE FIXED) { #convert samba-paths to local unix paths - $dbpaths[$i] = substr($dbpaths[$i], 23); # remove \\fileserver\wideprint\ + $dbpaths[$i] = substr($dbpaths[$i], 13); # remove \\fileserver\ $dbpaths[$i] =~ tr/\\/\//; # convert each \ to / - $dbpaths[$i] = '/WIDEPRINT/' . $dbpaths[$i]; + $dbpaths[$i] = '/mnt/maket/' . $dbpaths[$i]; $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) ); # # We must not save non-existent local file in array! # Returning of array with bad element is deprecated, # So this code too weak to work correctly. # - if($EXPAND_SYMLINKS && -e $dbpaths[$i]) - { - chomp( $_ = `dirname $dbpaths[$i] | xargs /usr/bin/readlink` ); - chomp( $dbpaths[$i] = $_ . '/' . `basename $dbpaths[$i]` ); - - # increment $i ONLY if local file exists, otherwise replace element in next iteration - $i++; - } - # if localfile does not exists, write result of next iteration on its place + # increment $i ONLY if local file exists, otherwise replace element in next iteration + $i++; + # if localfile does not exists, write result of next iteration on its place } else { @@ -94,25 +88,20 @@ } -sub jpegs_list() +sub probas_list() { my @dbids; my @dbpaths; my $i = 0; - $sth = $db::dbh->prepare($QUERY_J); + $sth = $db::dbh->prepare($QUERY_P); $sth->execute( ); while(($dbids[$i], $dbpaths[$i]) = $sth->fetchrow_array( ) ) { - $dbpaths[$i] = substr($dbpaths[$i], 23); + $dbpaths[$i] = substr($dbpaths[$i], 13); $dbpaths[$i] =~ tr/\\/\//; - $dbpaths[$i] = '/WIDEPRINT/' . $dbpaths[$i]; + $dbpaths[$i] = '/mnt/maket/' . $dbpaths[$i]; $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) ); - if($EXPAND_SYMLINKS && -e $dbpaths[$i]) - { - chomp( $_ = `dirname $dbpaths[$i] | xargs /usr/bin/readlink` ); - chomp( $dbpaths[$i] = $_ . '/' . `basename $dbpaths[$i]` ); - } $i++; } @@ -121,31 +110,26 @@ $#dbpaths = $i; log::filelist(\@dbpaths); + return( (\@dbids, \@dbpaths) ); } - -sub probas_list() +sub tt_list() { my @dbids; my @dbpaths; my $i = 0; - - $sth = $db::dbh->prepare($QUERY_P); + + $sth = $db::dbh->prepare($QUERY_T); $sth->execute( ); while(($dbids[$i], $dbpaths[$i]) = $sth->fetchrow_array( ) ) { - $dbpaths[$i] = substr($dbpaths[$i], 23); - $dbpaths[$i] =~ tr/\\/\//; - $dbpaths[$i] = '/WIDEPRINT/' . $dbpaths[$i]; - $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) ); - if($EXPAND_SYMLINKS && -e $dbpaths[$i]) - { - chomp( $_ = `dirname $dbpaths[$i] | xargs /usr/bin/readlink` ); - chomp( $dbpaths[$i] = $_ . '/' . `basename $dbpaths[$i]` ); - } - $i++; + $dbpaths[$i] = substr($dbpaths[$i], 13); + $dbpaths[$i] =~ tr/\\/\//; + $dbpaths[$i] = '/mnt/maket/' . $dbpaths[$i]; + $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) ); + $i++; } $i--; @@ -154,31 +138,25 @@ log::filelist(\@dbpaths); - + return( (\@dbids, \@dbpaths) ); } - -sub tpps_list() +sub zjpeg_list() { my @dbids; my @dbpaths; my $i = 0; - - $sth = $db::dbh->prepare($QUERY_T); + + $sth = $db::dbh->prepare($QUERY_ZJ); $sth->execute( ); while(($dbids[$i], $dbpaths[$i]) = $sth->fetchrow_array( ) ) { - $dbpaths[$i] = substr($dbpaths[$i], 23); - $dbpaths[$i] =~ tr/\\/\//; - $dbpaths[$i] = '/WIDEPRINT/' . $dbpaths[$i]; - $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) ); - if($EXPAND_SYMLINKS && -e $dbpaths[$i]) - { - chomp( $_ = `dirname $dbpaths[$i] | xargs /usr/bin/readlink` ); - chomp( $dbpaths[$i] = $_ . '/' . `basename $dbpaths[$i]` ); - } - $i++; + $dbpaths[$i] = substr($dbpaths[$i], 13); + $dbpaths[$i] =~ tr/\\/\//; + $dbpaths[$i] = '/mnt/maket/' . $dbpaths[$i]; + $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) ); + $i++; } $i--; @@ -186,9 +164,36 @@ $#dbpaths = $i; log::filelist(\@dbpaths); - + + return( (\@dbids, \@dbpaths) ); } +sub pjpeg_list() +{ + my @dbids; + my @dbpaths; + my $i = 0; + + $sth = $db::dbh->prepare($QUERY_PJ); + $sth->execute( ); + while(($dbids[$i], $dbpaths[$i]) = $sth->fetchrow_array( ) ) + { + $dbpaths[$i] = substr($dbpaths[$i], 13); + $dbpaths[$i] =~ tr/\\/\//; + $dbpaths[$i] = '/mnt/maket/' . $dbpaths[$i]; + $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) ); + $i++; + } + + $i--; + $#dbids = $i; + $#dbpaths = $i; + + log::filelist(\@dbpaths); + + + return( (\@dbids, \@dbpaths) ); +} return(1);