Changeset 67


Ignore:
Timestamp:
11/29/05 01:39:36 (19 years ago)
Author:
thauvin
Message:
  • rename variable to be coherent with new code
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/soft/ObsData/ObsData/Repository.pm

    • Property cvs2svn:cvs-rev changed from 1.13 to 1.14
    r66 r67  
    9191} 
    9292 
    93 sub install_file { 
    94     my ($self, $file) = @_; 
    95      
    96 } 
    97  
    9893package ObsData::Repository::archive; 
    9994 
     
    10196 
    10297sub new { 
    103     my ($class, $or, $archive) = @_; 
    104      
    105     my $newor = { %$or }; 
    106  
    107     $newor->{archive} = $archive; 
    108      
    109     bless($newor, $class); 
     98    my ($class, $parent, $archivefile) = @_; 
     99     
     100    my $ORa = { %$parent }; 
     101 
     102    $ORa->{archivefile} = $archivefile; 
     103     
     104    bless($ORa, $class); 
    110105} 
    111106 
     
    119114    my ($self) = @_; 
    120115 
    121     my $file = $self->{archive}; # quick compatibility 
    122  
    123     my @filestats = stat("$self->{dir}/$file"); 
     116    my @filestats = stat("$self->{dir}/$self->{archivefile}"); 
    124117             
    125     if ($self->{status}->SectionExists($file)) { 
    126         $self->loging(0, "File %s found in status, checking...", $file); 
     118    if ($self->{status}->SectionExists($self->{archivefile})) { 
     119        $self->loging(0, "File %s found in status, checking...", $self->{archivefile}); 
    127120        my ($mtimeok, $sizeok) = (0, 0); 
    128         my $olddatatype = $self->{status}->val($file, 'datatype'); 
    129         my $oldmtime = $self->{status}->val($file, 'mtime'); 
    130         my $oldsize = $self->{status}->val($file, 'size'); 
     121        my $olddatatype = $self->{status}->val($self->{archivefile}, 'datatype'); 
     122        my $oldmtime = $self->{status}->val($self->{archivefile}, 'mtime'); 
     123        my $oldsize = $self->{status}->val($self->{archivefile}, 'size'); 
    131124        if ($oldmtime) { 
    132125            if ($oldmtime == $filestats[9]) { 
     
    154147            if (! ($sizeok && $mtimeok)) { 
    155148                $self->loging(3, "File %s allready processed but has changed:%s%s", 
    156                     $file, 
     149                    $self->{archivefile}, 
    157150                    ($sizeok ? "" : sprintf(" size %d => %d", $oldsize, $filestats[7])), 
    158151                    ($mtimeok ? "" : sprintf(" mtime %d => %d", $oldmtime, $filestats[9])), 
     
    163156        } else { 
    164157            if ($sizeok && $mtimeok) { 
    165                 $self->loging(0, "%s was not take into acount, no change skipping", $file); 
     158                $self->loging(0,  
     159                    "%s was not take into acount, no change skipping", 
     160                    $self->{archivefile} 
     161                ); 
    166162                return 0; 
    167163            } else { 
    168                 $self->loging(0, "%s file has not been processed, but change, retrying", $file); 
     164                $self->loging(0,  
     165                    "%s file has not been processed, but change, retrying", 
     166                    $self->{archivefile} 
     167                ); 
    169168                return 1; 
    170169            } 
     
    172171         
    173172    } else { 
    174         $self->loging(0, "%s is new files", $file); 
    175         $self->{status}->AddSection($file); 
    176         $self->{status}->newval($file, 'mtime', $filestats[9]); 
    177         $self->{status}->newval($file, 'size', $filestats[7]); 
     173        $self->loging(0, "%s is new files", $self->{archivefile}); 
     174        $self->{status}->AddSection($self->{archivefile}); 
     175        $self->{status}->newval($self->{archivefile}, 'mtime', $filestats[9]); 
     176        $self->{status}->newval($self->{archivefile}, 'size', $filestats[7]); 
    178177        return 1; 
    179178    } 
     
    182181sub parse_archive { 
    183182    my ($self) = @_; 
    184     my $file = $self->{archive}; # quick compatibility 
    185183 
    186184    my $newer = $self->file_need_parse(); 
    187185 
    188     $self->loging(0, "trying to read archive content of %s", $file); 
    189     $self->{Oarchive} = ObsData::Archive->new("$self->{dir}/$file") or do { 
     186    $self->loging(0, "trying to read archive content of %s", $self->{archivefile}); 
     187    $self->{Oarchive} = ObsData::Archive->new("$self->{dir}/$self->{archivefile}") or do { 
    190188        $self->loging(4,  
    191189            "Can't handle archive %s: %s, skipping", 
    192             $file, 
     190            $self->{archivefile}, 
    193191            ObsData::Archive->error 
    194192        ); 
     
    196194    }; 
    197195     
    198     foreach my $content ($self->{Oarchive}->ls) { 
    199         $self->loging(0, "archive %s: content %s", $file, $content); 
     196    foreach my $datafile ($self->{Oarchive}->ls) { 
     197        $self->loging(0, "archive %s: content %s", $self->{archivefile}, $datafile); 
    200198        my $data = ObsData::Repository::archive::data->new( 
    201199            $self, 
    202             $content, 
     200            $datafile, 
    203201        ); 
    204202        $data->dispatch; 
     
    211209 
    212210sub new { 
    213     my ($class, $or, $content) = @_; 
    214      
    215     my $newor = { %$or }; 
    216  
    217     $newor->{content} = $content; 
    218      
    219     bless($newor, $class); 
     211    my ($class, $parent, $datafile) = @_; 
     212     
     213    my $ORad = { %$parent }; 
     214 
     215    $ORad->{datafile} = $datafile; 
     216     
     217    bless($ORad, $class); 
    220218} 
    221219 
     
    228226sub dispatch { 
    229227    my ($self) = @_; 
    230     my $file = $self->{archive}; # quick compatibility 
    231     my $archive = $self->{Oarchive}; # quick compatibility 
    232     my $content = $self->{content}; # quick compatibility 
    233  
    234     my $last_process = $self->{status}->val($file, "data_processtime_$content"); 
     228 
     229    my $last_process = $self->{status}->val($self->{archivefile}, "data_processtime_$self->{datafile}"); 
    235230    if ($last_process) { 
    236231        $self->loging(0, "%s/%s has been already processed at %s, skipping", 
    237             $file, 
    238             $content, 
     232            $self->{archivefile}, 
     233            $self->{datafile}, 
    239234            scalar(localtime($last_process)), 
    240235        ); 
     
    243238     
    244239    my ($datatype, $destfile) = $self->{obsdata}->build_dest_filename( 
    245         $content,  
     240        $self->{datafile},  
    246241        $self->{datatype} 
    247242    ); 
    248243     
    249244    $self->loging(0, "%s/%s file, datatype %s, destination %s", 
    250         $file, $content, 
     245        $self->{archivefile}, 
     246        $self->{datafile}, 
    251247        $datatype || '(none)', 
    252248        $destfile || '(none)', 
     
    255251    my $ltime = time; 
    256252    $self->{status}->newval( 
    257         $file, 
    258         "data_processtime_$content", 
     253        $self->{archivefile}, 
     254        "data_processtime_$self->{datafile}", 
    259255        $ltime 
    260256    ); 
    261257    $self->{status}->SetParameterComment( 
    262         $file,  
    263         "data_processtime_$content", 
     258        $self->{archivefile},  
     259        "data_processtime_$self->{datafile}", 
    264260        $ObsData::CVSID, 
    265261        $ObsData::Repository::CVSID, 
     
    269265     
    270266    if (!$datatype) { 
    271         $self->loging(3, "I don't know what to do of %s/%s", $file, $content); 
     267        $self->loging(3, 
     268            "I don't know what to do of %s/%s", 
     269            $self->{archivefile}, 
     270            $self->{datafile} 
     271        ); 
    272272        return; 
    273273    } elsif ($destfile) { 
    274         $self->loging(0, "Extracting %s/%s to %s", $file, $content, $destfile); 
     274        $self->loging(0, 
     275            "Extracting %s/%s to %s", $self->{archivefile}, 
     276            $self->{datafile}, 
     277            $destfile 
     278        ); 
    275279 
    276280        my ($dirname) = $destfile =~ m!(?:(.*)/)?(.*)$!; #! vim syntax 
     
    283287        } 
    284288 
    285         if ($archive->extract($content, $destfile)) { 
    286             $self->{status}->newval($file, "data_type_$content", $datatype); 
    287             $self->{status}->newval($file, "data_dest_$content", $destfile); 
     289        if ($self->{Oarchive}->extract($self->{datafile}, $destfile)) { 
     290            $self->{status}->newval($self->{archivefile}, "data_type_$self->{datafile}", $datatype); 
     291            $self->{status}->newval($self->{archivefile}, "data_dest_$self->{datafile}", $destfile); 
    288292        } else { 
    289293            $self->loging( 
    290294                4, "Can't extract %s/%s to %s: %s", 
    291                 $file, $content, $destfile, 
    292                 $archive->error, 
     295                $self->{archivefile}, $self->{datafile}, $destfile, 
     296                $self->{Oarchive}->error, 
    293297            ); 
    294298        } 
     
    297301        $self->loging(3, 
    298302            "%s/%s has type %s but no destination", 
    299             $file, $content, $datatype 
     303            $self->{archivefile}, $self->{datafile}, $datatype 
    300304        ); 
    301305    } 
Note: See TracChangeset for help on using the changeset viewer.