Ignore:
Timestamp:
2018-11-20T10:54:07+13:00 (3 years ago)
Author:
kjdon
Message:

mods for incremental build. now we load in the reverse info db (archiveinf-src) and make changes to that, then write it out again at the end. did a bit of work to get html + supporting images working a bit better. for the cases where the main file is modified, or if the images are modified, or if links to those images are changed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/inexport.pm

    r32586 r32615  
    628628    my $archive_info = new arcinfo ($collectcfg->{'infodbtype'});
    629629    $archive_info->load_info ($arcinfo_doc_filename);
     630    # load in rev info so we don't overwrite existing info when we do incremental import
     631    # from here on, make all changes to this object, then write out the file at the end.
     632    $archive_info->load_rev_info($arcinfo_src_filename);
    630633
    631634    if ($manifest eq "") {
     
    713716    $block_hash->{'metadata_files'} = {};
    714717    $block_hash->{'shared_fileroot'} = '';
    715     # a new flag so we can tell we had a manifest way down in the plugins
    716     # [jmt12]
    717718    $block_hash->{'manifest'} = 'false';
    718719    my $metadata = {};
     
    855856        }
    856857      }
    857 
     858   
    858859      # If we are not using complex inherited metadata (and thus have skipped
    859860      # the global file scan) we need to at least check for a matching
     
    13741375
    13751376
    1376 # this is used to delete "deleted" docs, and to remove old versions of "changed" docs
     1377# this is used to delete "deleted" docs and to remove old versions of "changed" docs
    13771378# $mode is 'delete' or 'reindex'
    13781379sub mark_docs_for_deletion
     
    13961397    # use 'archiveinf-src' info database file to look up all the OIDs
    13971398    # that this file is used in (note in most cases, it's just one OID)
    1398    
    1399     my $relfile = &util::abspath_to_placeholders($file);
    1400 
    1401     my $src_rec = &dbutil::read_infodb_entry($infodbtype, $arcinfo_src_filename, $relfile);
    1402     my $oids = $src_rec->{'oid'};
    1403     my $file_record_deleted = 0;
    1404 
    1405     # delete the src record
    1406     my $src_infodb_file_handle = &dbutil::open_infodb_write_handle($infodbtype, $arcinfo_src_filename, "append");
    1407     &dbutil::delete_infodb_entry($infodbtype, $src_infodb_file_handle, $relfile);
    1408     &dbutil::close_infodb_write_handle($infodbtype, $src_infodb_file_handle);
    1409 
    1410 
    1411     foreach my $oid (@$oids) {
    1412 
     1399);
     1400    my $oids = $archive_info->get_reverseinfo($file);
     1401    $archive_info->remove_reverseinfo($file);
     1402   
     1403    foreach my $oid (@$oids) {
     1404        # get the record for this OID from doc db
     1405        my $doc_rec = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $oid);
    14131406        # find the source doc (the primary file that becomes this oid)
    1414         my $doc_rec = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $oid);
    14151407        my $doc_source_file = $doc_rec->{'src-file'}->[0];
    14161408        $doc_source_file = &util::placeholders_to_abspath($doc_source_file);
     
    14261418        $block_hash->{'reindex_files'}->{$doc_source_file} = 1;
    14271419       
     1420        } else {
     1421
     1422        # the file to be deleted/reindexed is a primary file. We need to remove all references to this in the src db
     1423        my $assoc_files = $doc_rec->{'assoc-file'};
     1424        foreach my $assocfile (@$assoc_files) {
     1425            $assocfile = &util::placeholders_to_abspath($assocfile);
     1426            $archive_info->remove_reverseinfo($assocfile, $oid);
     1427            if (!defined $archive_info->get_reverseinfo($assocfile)) {
     1428            # nothing refers to it anymore, mark for reindex.
     1429            $block_hash->{'reindex_files'}->{$assocfile} = 1;
     1430            }
     1431        }
     1432
    14281433        }
    14291434        my $curr_status = $archive_info->get_status_info($oid);
Note: See TracChangeset for help on using the changeset viewer.