Ignore:
Timestamp:
2005-08-04T15:25:24+12:00 (19 years ago)
Author:
kjdon
Message:

standardised -removeold and -keepold. if neither or both are specified, a warning is printed, and -removeold is used.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/export.pl

    r10340 r10417  
    5050use docprint;
    5151use util;
     52use scriptutil;
    5253use FileHandle;
    5354use gsprintf;
     
    225226    my $explicit_exportdir = (defined $exportdir) ? 1 : 0;
    226227
     228    # save these command line settings. don't want config file settings in one
     229    # coll used for other colls
     230    # does this apply to other vars???
     231    my $global_removeold = $removeold;
     232    my $global_keepold = $keepold;
    227233    # If $language has been specified, load the appropriate resource bundle
    228234    # (Otherwise, the default resource bundle will be loaded automatically)
     
    263269    $out->autoflush(1);
    264270
    265     # set removeold to false if it has been defined
    266     $removeold = 0 if ($keepold);
    267 
    268271    while (scalar(@ARGV)>0) {
    269272    my $collect_name = shift @ARGV;
    270 
    271273    $ENV{'GSDLCOLLECTION'} = $collect_name;
    272274
     
    308310       
    309311        $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
    310         if (-e $configfilename) {
    311         my $collectcfg = &colcfg::read_collect_cfg ($configfilename);
    312         if (defined $collectcfg->{'plugin'}) {
    313             $plugins = $collectcfg->{'plugin'};
    314         }
    315        
    316         if ($verbosity !~ /\d+/) {
    317             if (defined $collectcfg->{'verbosity'} && $collectcfg->{'verbosity'} =~ /\d+/) {
    318             $verbosity = $collectcfg->{'verbosity'};
    319             } else {
    320             $verbosity = 2; # the default
    321             }
    322         }
    323         if (defined $collectcfg->{'importdir'} && $importdir eq "") {
    324             $importdir = $collectcfg->{'importdir'};
    325         }
    326         if (defined $collectcfg->{'exportdir'} && $exportdir eq "") {
    327             $exportdir = $collectcfg->{'exportdir'};
    328         }
    329         if (defined $collectcfg->{'removeold'}) {
    330             if ($collectcfg->{'removeold'} =~ /^true$/i && !$keepold) {
    331             $removeold = 1;
    332             }
    333             if ($collectcfg->{'removeold'} =~ /^false$/i && !$removeold) {
    334             $removeold = 0;
    335             }
    336         }
    337         if (defined $collectcfg->{'keepold'}) {
    338             if ($collectcfg->{'keepold'} =~ /^false$/i && !$keepold) {
    339             $removeold = 1;
    340             }
    341         }
    342         if (defined $collectcfg->{'gzip'} && !$gzip) {
    343             if ($collectcfg->{'gzip'} =~ /^true$/i) {
    344             $gzip = 1;
    345             }
    346         }
    347         if ($maxdocs !~ /\-?\d+/) {
    348             if (defined $collectcfg->{'maxdocs'} && $collectcfg->{'maxdocs'} =~ /\-?\d+/) {
    349             $maxdocs = $collectcfg->{'maxdocs'};
    350             } else {
    351             $maxdocs = -1; # the default
    352             }
    353         }
    354         if ($groupsize == 1) {
    355             if (defined $collectcfg->{'groupsize'} && $collectcfg->{'groupsize'} =~ /\d+/) {
    356             $groupsize = $collectcfg->{'groupsize'};
    357             }
    358         }
    359         if (!defined $OIDtype || ($OIDtype !~ /^(hash|incremental)$/)) {
    360             if (defined $collectcfg->{'OIDtype'} && $collectcfg->{'OIDtype'} =~ /^(hash|incremental)$/) {
    361             $OIDtype = $collectcfg->{'OIDtype'};
    362             } else {
    363             $OIDtype = "hash"; # the default
    364             }
    365         }
    366         if (defined $collectcfg->{'sortmeta'} && $sortmeta eq "") {
    367             $sortmeta = $collectcfg->{'sortmeta'};
    368         }
    369         if (defined $collectcfg->{'debug'} && $collectcfg->{'debug'} =~ /^true$/i) {
    370             $debug = 1;
    371         }
    372         if (defined $collectcfg->{'gli'} && $collectcfg->{'gli'} =~ /^true$/i) {
    373             $gli = 1;
    374         }
    375        
    376         # global plugin stuff
    377         if (defined $collectcfg->{'separate_cjk'}&& $collectcfg->{'separate_cjk'} =~ /^true$/i) {
    378             push @global_opts, "-separate_cjk";
    379         }
    380         } else {
     312        if (!-e $configfilename) {
    381313        (&gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die);
    382314        }
    383315       
     316        my $collectcfg = &colcfg::read_collect_cfg ($configfilename);
     317        if (defined $collectcfg->{'plugin'}) {
     318        $plugins = $collectcfg->{'plugin'};
     319        }
     320       
     321        if ($verbosity !~ /\d+/) {
     322        if (defined $collectcfg->{'verbosity'} && $collectcfg->{'verbosity'} =~ /\d+/) {
     323            $verbosity = $collectcfg->{'verbosity'};
     324        } else {
     325            $verbosity = 2; # the default
     326        }
     327        }
     328        if (defined $collectcfg->{'importdir'} && $importdir eq "") {
     329        $importdir = $collectcfg->{'importdir'};
     330        }
     331        if (defined $collectcfg->{'exportdir'} && $exportdir eq "") {
     332        $exportdir = $collectcfg->{'exportdir'};
     333        }
     334
     335        if (defined $collectcfg->{'gzip'} && !$gzip) {
     336        if ($collectcfg->{'gzip'} =~ /^true$/i) {
     337            $gzip = 1;
     338        }
     339        }
     340        if ($maxdocs !~ /\-?\d+/) {
     341        if (defined $collectcfg->{'maxdocs'} && $collectcfg->{'maxdocs'} =~ /\-?\d+/) {
     342            $maxdocs = $collectcfg->{'maxdocs'};
     343        } else {
     344            $maxdocs = -1; # the default
     345        }
     346        }
     347        if ($groupsize == 1) {
     348        if (defined $collectcfg->{'groupsize'} && $collectcfg->{'groupsize'} =~ /\d+/) {
     349            $groupsize = $collectcfg->{'groupsize'};
     350        }
     351        }
     352        if (!defined $OIDtype || ($OIDtype !~ /^(hash|incremental)$/)) {
     353        if (defined $collectcfg->{'OIDtype'} && $collectcfg->{'OIDtype'} =~ /^(hash|incremental)$/) {
     354            $OIDtype = $collectcfg->{'OIDtype'};
     355        } else {
     356            $OIDtype = "hash"; # the default
     357        }
     358        }
     359        if (defined $collectcfg->{'sortmeta'} && $sortmeta eq "") {
     360        $sortmeta = $collectcfg->{'sortmeta'};
     361        }
     362        if (defined $collectcfg->{'debug'} && $collectcfg->{'debug'} =~ /^true$/i) {
     363        $debug = 1;
     364        }
     365        if (defined $collectcfg->{'gli'} && $collectcfg->{'gli'} =~ /^true$/i) {
     366        $gli = 1;
     367        }
     368       
     369        # global plugin stuff
     370        if (defined $collectcfg->{'separate_cjk'}&& $collectcfg->{'separate_cjk'} =~ /^true$/i) {
     371        push @global_opts, "-separate_cjk";
     372        }
     373       
     374        ($removeold, $keepold) = &scriptutil::check_removeold_and_keepold($global_removeold, $global_keepold, "export", $collectcfg);
     375
    384376        $gli = 0 unless defined $gli;
    385377
Note: See TracChangeset for help on using the changeset viewer.