Changeset 21620

Show
Ignore:
Timestamp:
25.01.2010 17:25:57 (9 years ago)
Author:
mdewsnip
Message:

Changed inexport.pm to use the infodbtype value from the collect.cfg file instead of hard-wiring GDBM. Part of making the code less GDBM-specific.

Files:
1 modified

Legend:

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

    r21619 r21620  
    8787    my ($archive_info,$block_hash,$importdir,$archivedir,$verbosity,$incremental_mode) = @_; 
    8888 
     89    # Get the infodbtype value for this collection from the arcinfo object 
     90    my $infodbtype = $archive_info->{'infodbtype'}; 
     91 
    8992    # in this method, we want to know if metadata files are modified or not. 
    90     my $arcinfo_doc_filename = &dbutil::get_infodb_file_path("gdbm", "archiveinf-doc", $archivedir); 
     93    my $arcinfo_doc_filename = &dbutil::get_infodb_file_path($infodbtype, "archiveinf-doc", $archivedir); 
    9194 
    9295    my $archiveinf_timestamp = -M $arcinfo_doc_filename; 
     
    286289    $mode_text = "reindexed"; 
    287290    } 
    288     my $arcinfo_doc_filename = &dbutil::get_infodb_file_path("gdbm", "archiveinf-doc", $archivedir); 
    289     my $arcinfo_src_filename = &dbutil::get_infodb_file_path("gdbm", "archiveinf-src", $archivedir); 
    290     my $doc_infodb_file_handle = &dbutil::open_infodb_write_handle("gdbm", $arcinfo_doc_filename, "append"); 
    291     my $src_infodb_file_handle = &dbutil::open_infodb_write_handle("gdbm", $arcinfo_src_filename, "append"); 
    292  
     291 
     292    # Get the infodbtype value for this collection from the arcinfo object 
     293    my $infodbtype = $archive_info->{'infodbtype'}; 
     294 
     295    my $arcinfo_doc_filename = &dbutil::get_infodb_file_path($infodbtype, "archiveinf-doc", $archivedir); 
     296    my $arcinfo_src_filename = &dbutil::get_infodb_file_path($infodbtype, "archiveinf-src", $archivedir); 
     297    my $doc_infodb_file_handle = &dbutil::open_infodb_write_handle($infodbtype, $arcinfo_doc_filename, "append"); 
     298    my $src_infodb_file_handle = &dbutil::open_infodb_write_handle($infodbtype, $arcinfo_src_filename, "append"); 
    293299 
    294300    # record files marked for deletion in arcinfo 
     
    297303    # that this file is used in (note in most cases, it's just one OID) 
    298304     
    299     my $src_rec_string = &dbutil::read_infodb_entry("gdbm", $arcinfo_src_filename, $file); 
     305    my $src_rec_string = &dbutil::read_infodb_entry($infodbtype, $arcinfo_src_filename, $file); 
    300306    my $src_rec = &dbutil::convert_infodb_string_to_hash($src_rec_string); 
    301307    my $oids = $src_rec->{'oid'}; 
     
    303309 
    304310    # delete the src record 
    305     &dbutil::delete_infodb_entry("gdbm", $src_infodb_file_handle, $file); 
     311    &dbutil::delete_infodb_entry($infodbtype, $src_infodb_file_handle, $file); 
    306312     
    307313    foreach my $oid (@$oids) { 
    308314 
    309315        # find the source doc (the primary file that becomes this oid) 
    310         my $doc_rec_string = &dbutil::read_infodb_entry("gdbm", $arcinfo_doc_filename, $oid); 
     316        my $doc_rec_string = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $oid); 
    311317        my $doc_rec = &dbutil::convert_infodb_string_to_hash($doc_rec_string); 
    312318        my $doc_source_file = $doc_rec->{'src-file'}->[0]; 
     
    329335        # mark oid for deletion (it will be deleted or reimported) 
    330336        $archive_info->set_status_info($oid,"D"); 
    331         my $val = &dbutil::read_infodb_entry("gdbm", $arcinfo_doc_filename, $oid); 
     337        my $val = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $oid); 
    332338        $val =~ s/^<index-status>(.*)$/<index-status>D/m; 
    333339 
    334340        my $val_rec = &dbutil::convert_infodb_string_to_hash($val); 
    335         &dbutil::write_infodb_entry("gdbm", $doc_infodb_file_handle, $oid, $val_rec); 
    336         } 
    337     } 
    338     } 
    339  
    340     &dbutil::close_infodb_write_handle("gdbm", $doc_infodb_file_handle); 
    341     &dbutil::close_infodb_write_handle("gdbm", $src_infodb_file_handle); 
     341        &dbutil::write_infodb_entry($infodbtype, $doc_infodb_file_handle, $oid, $val_rec); 
     342        } 
     343    } 
     344    } 
     345 
     346    &dbutil::close_infodb_write_handle($infodbtype, $doc_infodb_file_handle); 
     347    &dbutil::close_infodb_write_handle($infodbtype, $src_infodb_file_handle); 
    342348} 
    343349