[BACK]Return to fetch.pm CVS log [TXT][DIR] Up to [local] / wpscripts / ztransfer

Diff for /wpscripts/ztransfer/fetch.pm between version 1.2 and 1.7

version 1.2, 2011/07/20 07:50:57 version 1.7, 2011/12/21 10:19:26
Line 4 
Line 4 
 use db;  use db;
 use log;  # bad! only for log::filelist()  use log;  # bad! only for log::filelist()
 use warnings;  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_Z = "SELECT ID,Path,file_priority FROM upload_files WHERE Status=0 AND type_file=0";
 my $QUERY_P = "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=1";
   my $QUERY_T = "SELECT ID,Path,file_priority FROM upload_files WHERE Status=0 AND type_file=2";
   my $QUERY_J = "SELECT ID,Path,file_priority FROM upload_files WHERE Status=0 AND type_file=3";
   
 my $sth;  my $sth;
   
Line 39 
Line 40 
             #convert samba-paths to local unix paths              #convert samba-paths to local unix paths
             $dbpaths[$i] = substr($dbpaths[$i], 13);    # remove \\fileserver\              $dbpaths[$i] = substr($dbpaths[$i], 13);    # remove \\fileserver\
             $dbpaths[$i] =~ tr/\\/\//;                  # convert each \ to /              $dbpaths[$i] =~ tr/\\/\//;                  # convert each \ to /
             $dbpaths[$i] = '/mnt/rmt_maket/' . $dbpaths[$i];              $dbpaths[$i] = '/mnt/maket/' . $dbpaths[$i];
             $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) );              $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) );
                 #                  #
                 # We must not save non-existent local file in array!                  # We must not save non-existent local file in array!
                 # Returning of array with bad element is deprecated,                  # Returning of array with bad element is deprecated,
                 # So this code too weak to work correctly.                  # So this code too weak to work correctly.
                 #                  #
                 if($EXPAND_SYMLINKS && -e $dbpaths[$i])          # increment $i ONLY if local file exists, otherwise replace element in next iteration
                 {              $i++;
                     chomp( $_ = `dirname $dbpaths[$i] | xargs /usr/bin/readlink` );          # if localfile does not exists, write result of next iteration on its place
                     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  
         }          }
         else          else
         {          {
Line 92 
Line 87 
 }  }
   
   
 sub jpegs_list()  sub probas_list()
 {  {
     my @dbids;      my @dbids;
     my @dbpaths;      my @dbpaths;
     my $i = 0;      my $i = 0;
   
     $sth = $db::dbh->prepare($QUERY_J);      $sth = $db::dbh->prepare($QUERY_P);
     $sth->execute( );      $sth->execute( );
     while(($dbids[$i], $dbpaths[$i]) = $sth->fetchrow_array( ) )      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] =~ tr/\\/\//;
         $dbpaths[$i] = '/WIDEPRINT/' . $dbpaths[$i];          $dbpaths[$i] = '/mnt/maket/' . $dbpaths[$i];
         $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) );          $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++;          $i++;
     }      }
   
Line 119 
Line 109 
     $#dbpaths = $i;      $#dbpaths = $i;
   
     log::filelist(\@dbpaths);      log::filelist(\@dbpaths);
   
   
     return( (\@dbids, \@dbpaths) );      return( (\@dbids, \@dbpaths) );
 }  }
   
   sub tt_list()
 sub probas_list()  
 {  {
     my @dbids;      my @dbids;
     my @dbpaths;      my @dbpaths;
     my $i = 0;      my $i = 0;
   
     $sth = $db::dbh->prepare($QUERY_P);      $sth = $db::dbh->prepare($QUERY_T);
     $sth->execute( );      $sth->execute( );
     while(($dbids[$i], $dbpaths[$i]) = $sth->fetchrow_array( ) )      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] =~ tr/\\/\//;
         $dbpaths[$i] = '/WIDEPRINT/' . $dbpaths[$i];          $dbpaths[$i] = '/mnt/maket/' . $dbpaths[$i];
         $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) );          $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) );
             if($EXPAND_SYMLINKS && -e $dbpaths[$i])          $i++;
             {  
                 chomp( $_ = `dirname $dbpaths[$i] | xargs /usr/bin/readlink` );  
                 chomp( $dbpaths[$i] = $_ . '/' . `basename $dbpaths[$i]` );  
             }  
         $i++;  
     }      }
   
     $i--;      $i--;
Line 152 
Line 137 
   
     log::filelist(\@dbpaths);      log::filelist(\@dbpaths);
   
   
     return( (\@dbids, \@dbpaths) );      return( (\@dbids, \@dbpaths) );
 }  }
   
   sub jpeg_list()
 sub tpps_list()  
 {  {
     my @dbids;      my @dbids;
     my @dbpaths;      my @dbpaths;
     my $i = 0;      my $i = 0;
   
     $sth = $db::dbh->prepare($QUERY_T);      $sth = $db::dbh->prepare($QUERY_J);
     $sth->execute( );      $sth->execute( );
     while(($dbids[$i], $dbpaths[$i]) = $sth->fetchrow_array( ) )      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] =~ tr/\\/\//;
         $dbpaths[$i] = '/WIDEPRINT/' . $dbpaths[$i];          $dbpaths[$i] = '/mnt/maket/' . $dbpaths[$i];
         $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) );          $dbpaths[$i] = substr($dbpaths[$i], 0, ( index($dbpaths[$i], ' ', 0) ) );
             if($EXPAND_SYMLINKS && -e $dbpaths[$i])          $i++;
             {  
                 chomp( $_ = `dirname $dbpaths[$i] | xargs /usr/bin/readlink` );  
                 chomp( $dbpaths[$i] = $_ . '/' . `basename $dbpaths[$i]` );  
             }  
         $i++;  
     }      }
   
     $i--;      $i--;
Line 184 
Line 163 
     $#dbpaths = $i;      $#dbpaths = $i;
   
     log::filelist(\@dbpaths);      log::filelist(\@dbpaths);
   
   
     return( (\@dbids, \@dbpaths) );      return( (\@dbids, \@dbpaths) );
 }  }
   
   
 return(1);  return(1);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.7

CVSweb