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

Diff for /wpscripts/ztransfer/send.pm between version 1.7 and 1.8

version 1.7, 2011/12/21 10:19:26 version 1.8, 2012/04/01 06:52:10
Line 11 
Line 11 
 our $SPOOL_ZAYAVKI        = "/mnt/archive/archive/wp/zayavki";  our $SPOOL_ZAYAVKI        = "/mnt/archive/archive/wp/zayavki";
 our $SPOOL_PROBAS         = "/mnt/archive/archive/wp/proba";  our $SPOOL_PROBAS         = "/mnt/archive/archive/wp/proba";
 our $SPOOL_TT             = "/mnt/archive/archive/wp/tt";  our $SPOOL_TT             = "/mnt/archive/archive/wp/tt";
 our $SPOOL_JPEG           = "/mnt/archive/archive/wp/jpeg";  our $SPOOL_ZJPEG           = "/mnt/archive/archive/wp/zjpeg";
   our $SPOOL_PJPEG           = "/mnt/archive/archive/wp/pjpeg";
 our $SPOOL_TMPDIR         = "/mnt/archive/archive/temp";  our $SPOOL_TMPDIR         = "/mnt/archive/archive/temp";
   
 # temp variables for map table lookup  # temp variables for map table lookup
Line 497 
Line 498 
  }   }
   
   
 sub jpeg()  sub zjpeg()
  {   {
      my @dbids;       my @dbids;
      my @localpaths;       my @localpaths;
Line 509 
Line 510 
   
      my $size_orig;       my $size_orig;
   
      ($dbids_ref, $localpaths_ref) = fetch::jpeg_list();       ($dbids_ref, $localpaths_ref) = fetch::zjpeg_list();
   
      @dbids = @$dbids_ref;       @dbids = @$dbids_ref;
      @localpaths = @$localpaths_ref;       @localpaths = @$localpaths_ref;
      log::main("Fetched " . scalar(@localpaths) . " jpeg from database");       log::main("Fetched " . scalar(@localpaths) . " zjpeg from database");
      log::jpeg("<<  Starting transfer process  >>");       log::zjpeg("<<  Starting transfer process  >>");
   
      @remotepaths = @localpaths;  # clone       @remotepaths = @localpaths;  # clone
   
Line 547 
Line 548 
                  # set $size_orig                   # set $size_orig
                  $size_orig = -s "$localpaths[$i]";                   $size_orig = -s "$localpaths[$i]";
   
                  log::tt("transferring $localpaths[$i] -> $remotepaths[$i]");                   log::zjpeg("transferring $localpaths[$i] -> $remotepaths[$i]");
                  if( system("cp '$localpaths[$i]' '$remotepaths[$i]'") == 0 )                   if( system("cp '$localpaths[$i]' '$remotepaths[$i]'") == 0 )
                  {                   {
                          log::jpeg("saved $localpaths[$i] -> $remotepaths[$i] [size_orig=$size_orig]");                           log::zjpeg("saved $localpaths[$i] -> $remotepaths[$i] [size_orig=$size_orig]");
                          # update database                           # update database
                          db::change_status($dbids[$i], 1);                           db::change_status($dbids[$i], 1);
                          db::write_size_orig($dbids[$i], $size_orig);                           db::write_size_orig($dbids[$i], $size_orig);
Line 562 
Line 563 
                  else                   else
                  {                   {
                      # error in the copy process                       # error in the copy process
                      log::jpeg("error in copy process (see error log)");                       log::zjpeg("error in copy process (see error log)");
                      log::error("error in copy process: $?");                       log::error("error in copy process: $?");
                  }                   }
              }               }
Line 570 
Line 571 
              {               {
                  # error, local file doesn't exists                   # error, local file doesn't exists
                  log::error("Can not open local file $localpaths[$i]");                   log::error("Can not open local file $localpaths[$i]");
                  log::jpeg("Can not open local file $localpaths[$i]");                   log::zjpeg("Can not open local file $localpaths[$i]");
              }               }
          }           }
   
Line 578 
Line 579 
          $i++;           $i++;
      }       }
   
      log::main("Saved $okay jpeg on remote host");       log::main("Saved $okay zjpeg on remote host");
      log::jpeg("<<  End transfer process  >>");       log::zjpeg("<<  End transfer process  >>");
    }
   
   sub pjpeg()
    {
        my @dbids;
        my @localpaths;
        my @remotepaths;
        my $dbids_ref;
        my $localpaths_ref;
        my $i = 0;
        my $okay = 0;
   
        my $size_orig;
   
        ($dbids_ref, $localpaths_ref) = fetch::pjpeg_list();
   
        @dbids = @$dbids_ref;
        @localpaths = @$localpaths_ref;
        log::main("Fetched " . scalar(@localpaths) . " pjpeg from database");
        log::pjpeg("<<  Starting transfer process  >>");
   
        @remotepaths = @localpaths;  # clone
   
        while($localpaths[$i])
        {
            # lookup in table first
            chomp( $tmpf = `basename $remotepaths[$i]` );
            chomp( $_ = `dirname $remotepaths[$i]` );
            $tmpd = hash::lookup($_);
            if ( $tmpd ne '' )
            {
                $remotepaths[$i] =  $tmpd. "/". $tmpf;
            }
            else
            {
                # hardcoded
                $remotepaths[$i] =~ s/\/mnt\/maket/\/mnt\/rmt_maket/;
            }
   
            if(-e $remotepaths[$i])
            {
                log::error("Remote file $remotefile[$i] already exists");
                db::change_status($dbids[$i], 1);
            }
            else
            {
                if( -e $localpaths[$i] )
                {
                    fileops::checkdir($remotepaths[$i]);
                    # set $size_orig
                    $size_orig = -s "$localpaths[$i]";
   
                    log::pjpeg("transferring $localpaths[$i] -> $remotepaths[$i]");
                    if( system("cp '$localpaths[$i]' '$remotepaths[$i]'") == 0 )
                    {
                            log::pjpeg("saved $localpaths[$i] -> $remotepaths[$i] [size_orig=$size_orig]");
                            # update database
                            db::change_status($dbids[$i], 1);
                            db::write_size_orig($dbids[$i], $size_orig);
   
   
                            $okay++;
   
                    }
                    else
                    {
                        # error in the copy process
                        log::pjpeg("error in copy process (see error log)");
                        log::error("error in copy process: $?");
                    }
                }
                else
                {
                    # error, local file doesn't exists
                    log::error("Can not open local file $localpaths[$i]");
                    log::pjpeg("Can not open local file $localpaths[$i]");
                }
            }
   
            # next iteration of 'while' and increment of $i
            $i++;
        }
   
        log::main("Saved $okay pjpeg on remote host");
        log::pjpeg("<<  End transfer process  >>");
  }   }
   
 return(1);  return(1);

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

CVSweb