Changeset 73


Ignore:
Timestamp:
11/30/05 01:49:31 (19 years ago)
Author:
thauvin
Message:
  • to see if file need to be recheck, take into account config file mtime
Location:
trunk/soft/ObsData
Files:
2 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.17 to 1.18
    r70 r73  
    112112#} 
    113113 
     114# TODO Define return code for this function, storing result somewhere to 
     115# pass to child. 
    114116sub file_need_parse { 
    115117    my ($self) = @_; 
     
    119121    if ($self->{status}->SectionExists($self->{archivefile})) { 
    120122        $self->loging(0, "File %s found in status, checking...", $self->{archivefile}); 
    121         my ($mtimeok, $sizeok) = (0, 0); 
     123        my ($mtimeok, $sizeok, $conftimeok) = (0, 0, 0); 
    122124        my $olddatatype = $self->{status}->val($self->{archivefile}, 'datatype'); 
    123125        my $oldmtime = $self->{status}->val($self->{archivefile}, 'mtime'); 
    124126        my $oldsize = $self->{status}->val($self->{archivefile}, 'size'); 
     127        my $oldconftime = $self->{status}->val($self->{archivefile}, 'configtime'); 
    125128        if ($oldmtime) { 
    126129            if ($oldmtime == $filestats[9]) { 
     
    143146            } 
    144147        } 
     148        
     149        # Comparing time of the conf with time of conf during last process 
     150        # if config has changed, maybe something better will happend 
     151        my $configtime = (stat($self->{obsdata}->{config}->GetFileName))[9]; 
     152        if (defined($oldconftime) && $configtime <= $oldconftime) { 
     153            $conftimeok = 1; 
     154        } 
    145155         
    146156        #if ($olddatatype) { 
     
    152162                    ($mtimeok ? "" : sprintf(" mtime %d => %d", $oldmtime, $filestats[9])), 
    153163                ); 
    154             } 
    155         #    $self->loging(0, "%s has been allready processed: was %s", $file, $olddatatype); 
     164            } elsif (!$conftimeok) { 
     165                $self->loging(0, "config has changed since last process: %d vs %d, retrying it", 
     166                    $oldconftime, 
     167                    $configtime 
     168                ); 
     169                return 1; 
     170            } 
    156171            return 0; 
    157172        } else { 
     
    174189        $self->loging(0, "%s is new files", $self->{archivefile}); 
    175190        $self->{status}->AddSection($self->{archivefile}); 
    176         $self->{status}->newval($self->{archivefile}, 'mtime', $filestats[9]); 
    177         $self->{status}->newval($self->{archivefile}, 'size', $filestats[7]); 
     191        $self->update_status; 
    178192        return 1; 
    179193    } 
     194} 
     195 
     196sub update_status { 
     197    my ($self) = @_; 
     198    my @filestats = stat("$self->{dir}/$self->{archivefile}"); 
     199     
     200    $self->{status}->newval($self->{archivefile}, 'mtime', $filestats[9]); 
     201    $self->{status}->newval($self->{archivefile}, 'size', $filestats[7]); 
     202 
     203    my $configtime = (stat($self->{obsdata}->{config}->GetFileName))[9]; 
     204    $self->{status}->newval($self->{archivefile}, 'configtime', $configtime); 
    180205} 
    181206 
     
    194219        return; 
    195220    }; 
    196      
     221 
     222    $self->update_status; 
    197223    foreach my $datafile ($self->{Oarchive}->ls) { 
    198224        $self->loging(0, "archive %s: content %s", $self->{archivefile}, $datafile); 
     
    225251#} 
    226252 
    227 sub dispatch { 
    228     my ($self) = @_; 
    229  
     253# TODO Define return code for this function, storing result somewhere to 
     254# pass to child. 
     255sub data_need_parse { 
     256    my ($self) = @_; 
    230257    my $last_process = $self->{status}->val($self->{archivefile}, "data_processtime_$self->{datafile}"); 
    231258    if ($last_process) { 
     
    237264        return; 
    238265    } 
     266    return 1; 
     267} 
     268 
     269sub dispatch { 
     270    my ($self) = @_; 
     271 
     272    $self->data_need_parse or return; 
    239273     
    240274    my ($datatype, $destfile) = $self->{obsdata}->build_dest_filename( 
  • trunk/soft/ObsData/bin/obsdata

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r71 r73  
    1414    'logfile=s' => \my $log, 
    1515    'i|init' => \my $init, 
    16     'debug' => \my $debug, 
     16    'debug' => sub { $verbose = 0 }, 
    1717    'v' => sub { $verbose-- }, 
    1818); 
     
    2121    $configfile, 
    2222    logfile => $log, 
    23     verbose => $debug ? 0 : undef, 
     23    verbose => 0, 
    2424    logcallback => sub { 
    2525        return if($_[0] < $verbose); 
Note: See TracChangeset for help on using the changeset viewer.