Ignore:
Timestamp:
2023-04-27T15:53:20+12:00 (12 months ago)
Author:
davidb
Message:

Updated code to allow two import.pl's in a row (without a buildcol.pl) operate sensibly

File:
1 edited

Legend:

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

    r37689 r37730  
    504504            }
    505505            elsif ($index_status eq "I") {
    506             print STDERR "  Newly generated version of document from 'import/' of existing document from 'archives/' (Index-Status=I)\n";
    507             print STDERR "  => keepold: store snapshot of previous version in $FLDV_HISTORY_DIR as 'nminus-1'\n";
    508             prepend_document_version($keepold_doc_dirname,$doc_dirname);
     506
     507            if (!&FileUtils::directoryExists($doc_dirname)) {
     508                # This can happen if import.pl has been run twice in a row , without buildcol.pl
     509                #
     510                # Specifics: In the case that the second import.pl run is incremental, then previous "I" entries
     511                # from the first import.pl have not been processed by buildcol.pl and turned into "B" entries.
     512                # However, if existing "I" entries have not been modified between the first and second import.pl
     513                # then there is is no 'doc_dirname' that has been created in the newly formed archives.  Further,
     514                # the archives_keepold version isn't an example of a document that needs a "fldv" bump.
     515
     516                # long description to say, that basically we want to treat the situation like a "B", that
     517                # it's been index
     518
     519                print STDERR "  Unchanged version of document in 'archives/' however (Index-Status=I not B)\n";
     520                print STDERR "  This can occur if two consecutive import.pl's have been run, without a buildcol.pl inbetween\n";
     521                print STDERR "  => Recusirvely copying the archives_keepold/ doc across verbatim to archives/\n";
     522                print STDERR "     (effectively treating as a 'B')\n";
     523               
     524                doc_copy_archivedir_keepold_to_archivedir($keepold_doc_dirname,$doc_dirname);               
     525            }
     526            else {
     527                print STDERR "  Newly generated version of document from 'import/' of existing document from 'archives/' (Index-Status=I)\n";
     528                print STDERR "  => keepold: store snapshot of previous version in $FLDV_HISTORY_DIR as 'nminus-1'\n";
     529               
     530                prepend_document_version($keepold_doc_dirname,$doc_dirname);
     531            }
    509532            }
    510533            elsif ($index_status eq "B") {
     
    541564            }
    542565            elsif ($index_status eq "I") {
    543             print STDERR "  Newly generated version of document from 'import/' of existing document from 'archives/' (Index-Status=I)\n";
    544             print STDERR "  => keepold: store snapshot of previous version in $FLDV_HISTORY_DIR as 'nminus-1'\n";
    545             replace_document_version($keepold_doc_dirname,$doc_dirname);
     566
     567            if (!&FileUtils::directoryExists($doc_dirname)) {
     568                # This can happen if import.pl has been run twice in a row , without buildcol.pl
     569                #
     570                # For explanation see above 'I' entry for -keepold
     571                #
     572                # Basically we want to treat the situation like a "B", that it's been index
     573
     574                print STDERR "  Unchanged version of document in 'archives/' however (Index-Status=I not B)\n";
     575                print STDERR "  This can occur if two consecutive import.pl's have been run, without a buildcol.pl inbetween\n";
     576                print STDERR "  => Recusirvely copying the archives_keepold/ doc across verbatim to archives/\n";
     577                print STDERR "     (effectively treating as a 'B')\n";
     578               
     579                doc_copy_archivedir_keepold_to_archivedir($keepold_doc_dirname,$doc_dirname);
     580            }
     581            else {
     582                print STDERR "  Newly generated version of document from 'import/' of existing document from 'archives/' (Index-Status=I)\n";
     583                print STDERR "  => keepold: store snapshot of previous version in $FLDV_HISTORY_DIR as 'nminus-1'\n";
     584                replace_document_version($keepold_doc_dirname,$doc_dirname);
     585            }
    546586            }
    547587            elsif ($index_status eq "B") {
Note: See TracChangeset for help on using the changeset viewer.