Ignore:
Timestamp:
2016-12-09T21:24:55+13:00 (7 years ago)
Author:
ak19
Message:

This commit is related to but not specific to the upcoming commit to do with the new oaiinfo db and its directly affected files. This commit: New remove and rename (move) methods in DB package to clean up main db file and any additional db files created by any specific infodbtype. The new methods in dbutil/jdbm.pm are not called, for some reason. Requires more investigation, but committing for now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/dbutil/jdbm.pm

    r28395 r31188  
    306306
    307307
    308 
    309308sub delete_infodb_entry
    310309{
     
    320319
    321320
    322 
    323 
     321# jdb also creates .lg log files, that don't get removed on delete or move operations
     322# Make sure to rename them to when performing a rename operation on the main db file.
     323# dbutil::renameTo(src,dest) already took care of renaming the main db file.
     324sub rename_db_file_to {
     325    my $infodb_handle = shift(@_);
     326    my ($srcpath, $destpath) = @_;
     327
     328    my ($srctailname, $srcdirname, $srcsuffix)
     329    = &File::Basename::fileparse($srcpath, "\\.[^\\.]+\$");
     330    my ($desttailname, $destdirname, $destsuffix)
     331    = &File::Basename::fileparse($destpath, "\\.[^\\.]+\$");
     332
     333    # add in the lg extension
     334    my $src_log_file = &FileUtils::filenameConcatenate($srcdirname, $srctailname.".lg");
     335    my $dest_log_file = &FileUtils::filenameConcatenate($destdirname, $desttailname.".lg");
     336
     337    # finally, move/rename any log file belonging to the src db file
     338    if(&FileUtils::fileExists($src_log_file)) {
     339    &FileUtils::moveFiles($src_log_file, $dest_log_file);
     340    }
     341}
     342
     343sub remove_db_file {
     344    my $infodb_handle = shift(@_);
     345    my ($db_filepath) = @_;
     346
     347    # add in the lg extension to get the log file name
     348    my ($tailname, $dirname, $suffix) = &File::Basename::fileparse($db_filepath, "\\.[^\\.]+\$");
     349    my $assoc_log_file = &FileUtils::filenameConcatenate($dirname, $tailname.".lg");
     350
     351    # remove any log file associated with the db file
     352    if(&FileUtils::fileExists($assoc_log_file)) {
     353    &FileUtils::removeFiles($assoc_log_file);
     354    }
     355
     356}
    324357
    3253581;
Note: See TracChangeset for help on using the changeset viewer.