Changeset 28021

Show
Ignore:
Timestamp:
12.08.2013 10:47:22 (6 years ago)
Author:
jmt12
Message:

Found a bug in that I was defaulting 'subdir_hash_prefix' (the flag that controls whether the HASH prefix is counted against the archives subdirectory split length) to 'false'--which unfortunately evaluates as true in if statements---instead of '0'

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugouts/BasePlugout.pm

    r27880 r28021  
    9393     'type' => "flag", 
    9494     'reqd' => "no", 
    95          'deft' => "false", 
     95         'deft' => "0", 
    9696     'hiddengli' => "no"}, 
    9797       { 'name' => 'no_rss', 
     
    158158    } 
    159159 
    160     $self->{'gs_count'} = 0;     
    161  
    162     $self->{'keep_import_structure'} = 0;  
     160    $self->{'gs_count'} = 0; 
     161 
     162    $self->{'keep_import_structure'} = 0; 
    163163 
    164164    return bless $self, $class; 
     
    171171    my $header = shift(@_); 
    172172    my $high_level_information_only = shift(@_); 
    173      
     173 
    174174    # XML output is always in UTF-8 
    175175    gsprintf::output_strings_in_UTF8; 
     
    670670# Once a doc object is ready to write to disk (and hence has a nice OID), 
    671671# generate a unique subdirectory to write the information to. 
     672# 
    672673# - create the directory as part of this call, to try and avoid race conditions 
    673674#   found in parallel processing [jmt12] 
     675# 
     676# @todo figure out what the rule regarding $work_info->size() is meant to do 
     677# 
     678# @todo determine what $self->{'group'} is, and whether it should affect 
     679#       directory creation 
    674680# 
    675681sub get_new_doc_dir 
     
    704710      $doc_dir .= '/'; 
    705711    } 
     712 
    706713    # the default matching pattern grabs the next 'subdir_split_length' 
    707714    # characters of the OID to act as the next subdirectory 
    708715    my $pattern = '^(.{1,' . $self->{'subdir_split_length'} . '})'; 
     716 
    709717    # Do we count any "HASH" prefix against the split length limit? 
     718    print "[DEBUG] SubDir Hash Prefix: |" . $self->{'subdir_hash_prefix'} . "|\n"; 
    710719    if ($self->{'subdir_hash_prefix'} && $doc_dir_num == 0) 
    711720    { 
    712721      $pattern = '^((HASH)?.{1,' . $self->{'subdir_split_length'} . '})'; 
    713722    } 
     723 
     724    print "[DEBUG] Pattern: |" . $pattern . "|\n"; 
     725 
     726 
    714727    # Note the use of 's' to both capture the next chuck of OID and to remove 
    715728    # it from OID at the same time 
     
    718731      $doc_dir .= $1; 
    719732      $doc_dir_num++; 
    720       my $full_doc_dir = &FileUtils::filenameConcatenate($working_dir, $doc_dir . '.dir'); 
    721       if(!FileUtils::directoryExists($full_doc_dir)) { 
    722         &FileUtils::makeAllDirectories($full_doc_dir); 
    723         $created_directory = 1; 
    724       } 
    725     } 
    726     ###my $new_dir = &FileUtils::filenameConcatenate($working_dir, $doc_dir . '.dir'); 
    727     ###rint STDERR "[DEBUG] BasePlugout::get_new_doc_dir(<working_info>, $working_dir, $oid)\n"; 
    728     ###rint STDERR " - create directory: $new_dir => $created_directory\n"; 
    729     ###rint STDERR " - rest: $doc_dir_rest\n"; 
    730     ###rint STDERR " - working_info->size(): " . $working_info->size() . " [ < 1024 ?]\n"; 
    731     ###rint STDERR " - doc_dir_num: " . $doc_dir_num . "\n"; 
     733 
     734      my $full_doc_dir = &FileUtils::filenameConcatenate($working_dir, $doc_dir . '.dir'); 
     735      if(!FileUtils::directoryExists($full_doc_dir)) 
     736      { 
     737        &FileUtils::makeAllDirectories($full_doc_dir); 
     738        $created_directory = 1; 
     739      } 
     740 
     741      ###rint STDERR "[DEBUG] BasePlugout::get_new_doc_dir(<working_info>, $working_dir, $oid)\n"; 
     742      ###rint STDERR " - create directory: $full_doc_dir => $created_directory\n"; 
     743      ###rint STDERR " - rest: $doc_dir_rest\n"; 
     744      ###rint STDERR " - working_info->size(): " . $working_info->size() . " [ < 1024 ?]\n"; 
     745      ###rint STDERR " - doc_dir_num: " . $doc_dir_num . "\n"; 
     746    } 
    732747  } 
    733748  while ($doc_dir_rest ne '' && ($created_directory == 0 || ($working_info->size() >= 1024 && $doc_dir_num < 2))); 
     
    940955    } 
    941956 
    942     my $rss_filename = &FileUtils::filenameConcatenate($output_dir,"rss-items.rdf"); 
    943         my $rss_fh; 
    944     if (&FileUtils::openFileHandle($rss_filename, '>>', \$rss_fh)) { 
    945         print $rss_fh "<item>\n"; 
    946         print $rss_fh "   <title>$dc_title</title>\n"; 
    947         print $rss_fh "   <link>_httpdomain__httpcollection_/document/$oid</link>\n"; 
    948         print $rss_fh "</item>\n"; 
     957        my $rss_entry = "<item>\n"; 
     958        $rss_entry   .= "   <title>$dc_title</title>\n"; 
     959    $rss_entry   .= "   <link>_httpdomain__httpcollection_/document/$oid</link>\n"; 
     960    $rss_entry   .= "</item>"; 
     961 
     962        if (defined(&dbutil::supportsRSS) && &dbutil::supportsRSS($infodbtype)) 
     963        { 
     964          my $rss_db = &dbutil::get_infodb_file_path($infodbtype, 'rss-items', $output_dir); 
     965          my $rss_db_fh = &dbutil::open_infodb_write_handle($infodbtype, $rss_db, 'append'); 
     966          &dbutil::write_infodb_rawentry($infodbtype, $rss_db_fh, $oid, $rss_entry); 
     967          &dbutil::close_infodb_write_handle($infodbtype, $rss_db_fh); 
     968        } 
     969        else 
     970        { 
     971          my $rss_filename = &FileUtils::filenameConcatenate($output_dir,"rss-items.rdf"); 
     972          my $rss_fh; 
     973          if (&FileUtils::openFileHandle($rss_filename, '>>', \$rss_fh)) 
     974          { 
     975        print $rss_fh $rss_entry . "\n"; 
    949976        &FileUtils::closeFileHandle($rss_filename, \$rss_fh); 
    950     } 
    951     else { 
     977          } 
     978          else 
     979          { 
    952980        print STDERR "**** Failed to open $rss_filename\n$!\n"; 
    953     } 
     981          } 
     982        } 
    954983      } 
    955984    }