Changeset 88


Ignore:
Timestamp:
12/01/05 19:00:57 (19 years ago)
Author:
thauvin
Message:
  • make function independent
Location:
trunk/soft/ObsData
Files:
2 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.29 to 1.30
    r87 r88  
    289289            next; 
    290290        } 
    291         $or->parse_files; 
     291        $or->process; 
    292292    } 
    293293} 
  • trunk/soft/ObsData/ObsData/Repository.pm

    • Property cvs2svn:cvs-rev changed from 1.26 to 1.27
    r87 r88  
    5555     
    5656    bless($or, $class); 
     57 
     58    $or->set_do_if_change; 
     59    $or; 
    5760} 
    5861 
     
    129132} 
    130133 
    131 sub parse_files { 
     134sub process { 
    132135    my ($self) = @_; 
    133136    $self->loging(0, "%s() start for %s", (caller(0))[3], $self->{dir}); 
     
    138141            archivefile => $file, 
    139142        ); 
    140         $orda->parse_archive; 
     143        $orda->process; 
    141144    } 
    142145} 
     
    164167#} 
    165168 
    166 sub see_archive_change { 
    167     my ($self) = @_; 
    168  
    169     my @filestats = stat("$self->{dir}/$self->{archivefile}"); 
     169sub get_info { 
     170    my ($self) = @_; 
     171 
     172    $self->{filestats} = [ stat("$self->{dir}/$self->{archivefile}") ]; 
     173 
     174    if (! @{$self->{filestats}}) { 
     175        $self->loging(4, 
     176            "Cannot get info of %s", 
     177            "$self->{dir}/$self->{archivefile}" 
     178        ); 
     179        return 0; 
     180    } 
    170181 
    171182    if ($self->{status}->SectionExists($self->{archivefile})) { 
    172183        if (my $oldmtime = $self->{status}->val($self->{archivefile}, 'mtime')) { 
    173             if ($oldmtime == $filestats[9]) { 
    174  
    175             } elsif ($oldmtime > $filestats[9]) { 
     184            if ($oldmtime == $self->{filestats}[9]) { 
     185 
     186            } elsif ($oldmtime > $self->{filestats}[9]) { 
    176187                $self->loging(3,  
    177188                    "Wahou, %s is older than my reference: %d => %d",  
    178189                    $oldmtime, 
    179                     $filestats[9], 
     190                    $self->{filestats}[9], 
    180191                ); 
    181192            } else { 
     
    184195                    $self->{archivefile}, 
    185196                    $oldmtime, 
    186                     $filestats[9], 
     197                    $self->{filestats}[9], 
    187198                ); 
    188199            } 
     
    190201 
    191202        if (defined(my $oldsize = $self->{status}->val($self->{archivefile}, 'size'))) { 
    192             if ($oldsize != $filestats[7]) { 
     203            if ($oldsize != $self->{filestats}[7]) { 
    193204                $self->{changes}{archive_size} = $self->loging(0,  
    194205                    "%s size differ %d => %d", 
    195206                    $self->{archivefile}, 
    196207                    $oldsize, 
    197                     $filestats[7], 
     208                    $self->{filestats}[7], 
    198209                ); 
    199210            } 
     
    210221            } 
    211222        } 
    212              
    213223    } else { 
    214224        $self->{changes}{archive_new} = 
    215225            $self->loging(0, "%s is new file", $self->{archivefile}); 
    216226    } 
     227    return 1; 
    217228} 
    218229 
     
    221232sub file_need_parse { 
    222233    my ($self) = @_; 
    223  
    224     $self->see_archive_change; 
    225234 
    226235    my $need = 0; 
     
    249258sub parse_archive { 
    250259    my ($self) = @_; 
    251  
    252     my $newer = $self->file_need_parse(); 
    253260 
    254261    $self->loging(0, "trying to read archive content of %s", $self->{archivefile}); 
     
    262269    }; 
    263270 
    264     $self->update_status; 
    265271    foreach my $datafile ($self->{Oarchive}->ls) { 
    266272        $self->loging(0, "archive %s: content %s", $self->{archivefile}, $datafile); 
     
    271277        $data->dispatch; 
    272278    } 
     279    return 1; 
     280} 
     281 
     282sub process { 
     283    my ($self) = @_; 
     284 
     285    if (!$self->get_info) { 
     286        return 0; 
     287    } 
     288 
     289    if ($self->file_need_parse) { 
     290        if (!$self->parse_archive) { 
     291            return 0; 
     292        } 
     293    } 
     294 
     295    $self->update_status; 
     296 
     297    return 1; 
    273298} 
    274299 
Note: See TracChangeset for help on using the changeset viewer.