Changeset 19498 for gsdl/trunk/perllib/inexport.pm
- Timestamp:
- 2009-05-18T11:00:51+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/inexport.pm
r19266 r19498 125 125 } 126 126 127 # figure o fif new file or not127 # figure out if new file or not 128 128 if (defined $full_prev_all_files->{$full_curr_file}) { 129 129 … … 152 152 # In building the final list of files to delete, we test to see if 153 153 # it exists on the filesystem and if it does (unusual for a file 154 # that's allegedly deleted!) 154 # that's allegedly deleted!), supress it from going into the final 155 155 # list 156 156 … … 175 175 176 176 177 sub is_assoc_file 178 { 179 my ($file,$doc_rec) = @_; 180 181 foreach my $af (@{$doc_rec->{'assoc-file'}}) { 182 return 1 if ($af eq $file); 183 } 184 185 return 0; 186 } 187 188 177 189 sub _mark_docs_for_deletion 178 190 { 179 my ($archive_info,$ deleted_files_ref,$archivedir,$verbosity,$mode_text) = @_;191 my ($archive_info,$block_hash,$deleted_files,$archivedir,$verbosity,$mode_text) = @_; 180 192 181 193 my $doc_db = "archiveinf-doc.gdb"; … … 186 198 187 199 # record files marked for deletion in arcinfo 188 foreach my $file (@$deleted_files _ref) {200 foreach my $file (@$deleted_files) { 189 201 # use 'archiveinf-src' GDBM file to look up all the OIDs 190 202 # this file is used in (note in most cases, it's just one OID) … … 194 206 foreach my $oid (@$oids) { 195 207 196 # Find out if it's a n assoc file or main doc208 # Find out if it's a main doc, assoc file, or metadata 197 209 198 210 my $doc_rec = GDBMUtils::gdbmRecordToHash($arcinfo_doc_filename,$oid); 199 if ($doc_rec->{'src-file'}->[0] eq $file) { 200 # It's the main doc 201 # => mark it for deletion 202 203 if ($verbosity>1) { 204 print STDERR "$oid ($file) marked to be $mode_text on next buildcol.pl\n"; 205 } 206 $archive_info->set_status_info($oid,"D"); 207 208 my $val = &GDBMUtils::gdbmDatabaseGet($arcinfo_doc_filename,$oid); 209 my ($index_status) = ($val =~ m/^<index-status>(.*)$/m); 210 if ($index_status ne "D") { 211 $val =~ s/^<index-status>(.*)$/<index-status>D/m; 212 &GDBMUtils::gdbmDatabaseSet($arcinfo_doc_filename,$oid,$val); 213 } 214 } 215 else { 211 212 if (is_assoc_file($file,$doc_rec)) { 216 213 # assoc file => mark it for re-indexing (safest thing to do) 217 214 my $curr_status = $archive_info->get_status_info($oid); … … 229 226 &GDBMUtils::gdbmDatabaseSet($arcinfo_doc_filename,$oid,$val); 230 227 } 228 GDBMUtils::gdbmDatabaseRemove($arcinfo_src_filename,$file); 231 229 } 232 233 GDBMUtils::gdbmDatabaseRemove($arcinfo_src_filename,$file); 230 else { 231 # either src-file or metadata.xml file linking to src-file 232 233 my $src_file; 234 235 if ($doc_rec->{'src-file'}->[0] ne $file) { 236 # it's a metadata file attached to this OID 237 # => workout the src-file it matches to 238 239 $src_file = $doc_rec->{'src-file'}->[0]; 240 241 my $src_filename = $src_file; 242 if (!&util::filename_is_absolute($src_file)) { 243 $src_filename = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},$src_file); 244 } 245 246 $block_hash->{'reindex_files'}->{$src_filename} = 1; 247 } 248 else { 249 # It's the main doc 250 # => make it the target and mark it for deletion 251 $src_file = $file; 252 } 253 254 # Whether the main file directly or indirectly, mark for deletion/reindex 255 256 if ($verbosity>1) { 257 print STDERR "$oid ($src_file) marked to be $mode_text on next buildcol.pl\n"; 258 } 259 $archive_info->set_status_info($oid,"D"); 260 261 my $val = &GDBMUtils::gdbmDatabaseGet($arcinfo_doc_filename,$oid); 262 my ($index_status) = ($val =~ m/^<index-status>(.*)$/m); 263 if ($index_status ne "D") { 264 $val =~ s/^<index-status>(.*)$/<index-status>D/m; 265 &GDBMUtils::gdbmDatabaseSet($arcinfo_doc_filename,$oid,$val); 266 } 267 268 GDBMUtils::gdbmDatabaseRemove($arcinfo_src_filename,$src_file); 269 } 270 234 271 } 235 272 } … … 245 282 sub mark_docs_for_reindex 246 283 { 247 my ($archive_info,$ existing_files_ref,$archivedir,$verbosity) = @_;284 my ($archive_info,$block_hash,$archivedir,$verbosity) = @_; 248 285 249 286 # Reindexing is accomplished by deleting the previously indexed … … 260 297 # deals with it appropriately. 261 298 299 my @existing_files = sort keys %{$block_hash->{'existing_files'}}; 300 262 301 my $doc_db = "archiveinf-doc.gdb"; 263 302 my $arcinfo_doc_filename = &util::filename_cat ($archivedir, $doc_db); 264 303 265 266 304 my $archiveinf_timestamp = -M $arcinfo_doc_filename; 267 305 268 my $reindex_files _ref= [];269 270 foreach my $existing_filename (@ $existing_files_ref) {306 my $reindex_files = []; 307 308 foreach my $existing_filename (@existing_files) { 271 309 272 310 if (-M $existing_filename < $archiveinf_timestamp) { … … 281 319 ### print STDERR "**** Deleting existing file: $existing_file\n"; 282 320 283 push(@$reindex_files_ref,$existing_file); 321 push(@$reindex_files,$existing_file); 322 $block_hash->{'reindex_files'}->{$existing_filename} = 1; 284 323 } 285 324 286 325 } 287 326 288 _mark_docs_for_deletion($archive_info,$reindex_files_ref,$archivedir,$verbosity, "reindex"); 289 290 return @$reindex_files_ref; 327 _mark_docs_for_deletion($archive_info,$block_hash,$reindex_files,$archivedir,$verbosity, "reindex"); 328 291 329 } 292 330
Note:
See TracChangeset
for help on using the changeset viewer.