Changeset 67
- Timestamp:
- 11/29/05 01:39:36 (19 years ago)
- 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 91 91 } 92 92 93 sub install_file {94 my ($self, $file) = @_;95 96 }97 98 93 package ObsData::Repository::archive; 99 94 … … 101 96 102 97 sub 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); 110 105 } 111 106 … … 119 114 my ($self) = @_; 120 115 121 my $file = $self->{archive}; # quick compatibility 122 123 my @filestats = stat("$self->{dir}/$file"); 116 my @filestats = stat("$self->{dir}/$self->{archivefile}"); 124 117 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}); 127 120 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'); 131 124 if ($oldmtime) { 132 125 if ($oldmtime == $filestats[9]) { … … 154 147 if (! ($sizeok && $mtimeok)) { 155 148 $self->loging(3, "File %s allready processed but has changed:%s%s", 156 $ file,149 $self->{archivefile}, 157 150 ($sizeok ? "" : sprintf(" size %d => %d", $oldsize, $filestats[7])), 158 151 ($mtimeok ? "" : sprintf(" mtime %d => %d", $oldmtime, $filestats[9])), … … 163 156 } else { 164 157 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 ); 166 162 return 0; 167 163 } 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 ); 169 168 return 1; 170 169 } … … 172 171 173 172 } 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]); 178 177 return 1; 179 178 } … … 182 181 sub parse_archive { 183 182 my ($self) = @_; 184 my $file = $self->{archive}; # quick compatibility185 183 186 184 my $newer = $self->file_need_parse(); 187 185 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 { 190 188 $self->loging(4, 191 189 "Can't handle archive %s: %s, skipping", 192 $ file,190 $self->{archivefile}, 193 191 ObsData::Archive->error 194 192 ); … … 196 194 }; 197 195 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); 200 198 my $data = ObsData::Repository::archive::data->new( 201 199 $self, 202 $ content,200 $datafile, 203 201 ); 204 202 $data->dispatch; … … 211 209 212 210 sub 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); 220 218 } 221 219 … … 228 226 sub dispatch { 229 227 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}"); 235 230 if ($last_process) { 236 231 $self->loging(0, "%s/%s has been already processed at %s, skipping", 237 $ file,238 $ content,232 $self->{archivefile}, 233 $self->{datafile}, 239 234 scalar(localtime($last_process)), 240 235 ); … … 243 238 244 239 my ($datatype, $destfile) = $self->{obsdata}->build_dest_filename( 245 $ content,240 $self->{datafile}, 246 241 $self->{datatype} 247 242 ); 248 243 249 244 $self->loging(0, "%s/%s file, datatype %s, destination %s", 250 $file, $content, 245 $self->{archivefile}, 246 $self->{datafile}, 251 247 $datatype || '(none)', 252 248 $destfile || '(none)', … … 255 251 my $ltime = time; 256 252 $self->{status}->newval( 257 $ file,258 "data_processtime_$ content",253 $self->{archivefile}, 254 "data_processtime_$self->{datafile}", 259 255 $ltime 260 256 ); 261 257 $self->{status}->SetParameterComment( 262 $ file,263 "data_processtime_$ content",258 $self->{archivefile}, 259 "data_processtime_$self->{datafile}", 264 260 $ObsData::CVSID, 265 261 $ObsData::Repository::CVSID, … … 269 265 270 266 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 ); 272 272 return; 273 273 } 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 ); 275 279 276 280 my ($dirname) = $destfile =~ m!(?:(.*)/)?(.*)$!; #! vim syntax … … 283 287 } 284 288 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); 288 292 } else { 289 293 $self->loging( 290 294 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, 293 297 ); 294 298 } … … 297 301 $self->loging(3, 298 302 "%s/%s has type %s but no destination", 299 $ file, $content, $datatype303 $self->{archivefile}, $self->{datafile}, $datatype 300 304 ); 301 305 }
Note: See TracChangeset
for help on using the changeset viewer.