Changeset 20788


Ignore:
Timestamp:
2009-10-07T15:23:22+13:00 (15 years ago)
Author:
kjdon
Message:

rewrote _mark_docs_for_deletion. I think the cases for assoc fiel and meta file are the same, so merged the two cases.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/inexport.pm

    r20776 r20788  
    249249}
    250250
    251 
     251# not used anymore
    252252sub is_assoc_file
    253253{
     
    266266
    267267
     268
     269# this is used to delete "deleted" docs, and to remove old versions of "changed" docs
    268270sub _mark_docs_for_deletion
    269271{
     
    284286    my $oids = $src_rec->{'oid'};
    285287    my $file_record_deleted = 0;
     288
     289    # delete the src record
     290    GDBMUtils::gdbmDatabaseRemove($arcinfo_src_filename,$file);
     291   
    286292    foreach my $oid (@$oids) {
    287         # Find out if it's a main doc, assoc file, or metadata
    288 
     293
     294        # find the source doc (the primary file that becomes this oid)
    289295        my $doc_rec = GDBMUtils::gdbmRecordToHash($arcinfo_doc_filename,$oid);
    290296        my $doc_source_file = $doc_rec->{'src-file'}->[0];
     
    293299        }
    294300
    295         if (is_assoc_file($file,$doc_rec)) {
    296         ## -- kjdon - here, do same thing as for metadata file??
    297         ## mark source for reimport??
    298         # assoc file => mark it for re-indexing (safest thing to do)
    299         my $curr_status = $archive_info->get_status_info($oid);
    300 
     301        if ($doc_source_file ne $file) {
     302        # its an associated or metadata file
     303       
    301304        # mark source doc for reimport as one of its assoc files has changed or deleted
    302305        $block_hash->{'reindex_files'}->{$doc_source_file} = 1;
    303         if (defined($curr_status) && (($curr_status ne "D") && ($curr_status ne "R"))) {
    304             if ($verbosity > 1) {
    305             print STDERR "$oid marked for (potential) reindexing\n";
    306             print STDERR "  (because associated file $file deleted)\n";
    307             }
    308             $archive_info->set_status_info($oid,"R");
    309 
    310             my $val = &GDBMUtils::gdbmDatabaseGet($arcinfo_doc_filename,$oid);
    311             $val =~ s/^<index-status>(.*)$/<index-status>R/m;
    312             &GDBMUtils::gdbmDatabaseSet($arcinfo_doc_filename,$oid,$val);
     306       
     307        }
     308        my $curr_status = $archive_info->get_status_info($oid);
     309        if (defined($curr_status) && (($curr_status ne "D"))) {
     310        if ($verbosity>1) {
     311            print STDERR "$oid ($doc_source_file) marked to be $mode_text on next buildcol.pl\n";
    313312        }
    314         GDBMUtils::gdbmDatabaseRemove($arcinfo_src_filename,$file) unless $file_record_deleted;
    315         $file_record_deleted = 1;
    316         }
    317         else {
    318         # either src-file or metadata.xml file linking to src-file
    319         # actually, metadata files should not get here, as are
    320         # processed earlier
    321 
    322         if ($doc_rec->{'src-file'}->[0] ne $file) {
    323             # it's a metadata file attached to this OID
    324             # => reindex the src-file it matches to
    325 
    326             $block_hash->{'reindex_files'}->{$doc_source_file} = 1;
    327 
    328             # remove the metadata file from the src-database
    329            
    330             GDBMUtils::gdbmDatabaseRemove($arcinfo_src_filename,$file) unless $file_record_deleted;
    331             $file_record_deleted = 1;
    332         }
    333 
    334         # Whether the main file directly or indirectly, mark for deletion/reindex
    335 
     313        # mark oid for deletion (it will be deleted or reimported)
     314        $archive_info->set_status_info($oid,"D");
    336315        my $val = &GDBMUtils::gdbmDatabaseGet($arcinfo_doc_filename,$oid);
    337         my ($index_status) = ($val =~ m/^<index-status>(.*)$/m);
    338 
    339         if ($index_status ne "D") {
    340             if ($verbosity>1) {
    341             print STDERR "$oid ($doc_source_file) marked to be $mode_text on next buildcol.pl\n";
    342             }
    343             $archive_info->set_status_info($oid,"D");
    344 
    345             $val =~ s/^<index-status>(.*)$/<index-status>D/m;
    346             &GDBMUtils::gdbmDatabaseSet($arcinfo_doc_filename,$oid,$val);
    347 
    348             GDBMUtils::gdbmDatabaseRemove($arcinfo_src_filename,$doc_source_file);
    349         }
    350 
    351 
    352         }
    353 
    354     }
    355     }
    356 }
    357 
     316        $val =~ s/^<index-status>(.*)$/<index-status>D/m;
     317        &GDBMUtils::gdbmDatabaseSet($arcinfo_doc_filename,$oid,$val);
     318        }
     319    }
     320    }
     321}
    358322
    359323sub mark_docs_for_deletion
Note: See TracChangeset for help on using the changeset viewer.