Changeset 27880

Show
Ignore:
Timestamp:
16.07.2013 15:40:31 (6 years ago)
Author:
ak19
Message:

Intermediate commit. Bugfix to what broke ISIS/Marc tutorials. The archives doc dirs for each of the many records were not being created. This is an intermediate commit that fixes the bug in the usual situation. Dr Bainbridge has a better solution in mind that, once John has created the parallel building FileUtils? subroutines for, will work in the parallel case too.

Files:
1 modified

Legend:

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

    r27697 r27880  
    623623} 
    624624 
     625# Before parallel building, this was the method that created the new doc dirs in archives 
     626sub get_new_doc_dir_OLD { 
     627   my $self = shift (@_);   
     628   my($working_info,$working_dir,$OID) = @_;       
     629    
     630    
     631   my $doc_dir = ""; 
     632   my $doc_dir_rest = $OID; 
     633 
     634   # remove any \ and / from the OID 
     635   $doc_dir_rest =~ s/[\\\/]//g; 
     636 
     637   # Remove ":" if we are on Windows OS, as otherwise they get confused with the drive letters 
     638   $doc_dir_rest =~ s/\://g if ($ENV{'GSDLOS'} =~ /^windows$/i); 
     639 
     640   my $doc_dir_num = 0; 
     641 
     642   do { 
     643       $doc_dir .= "/" if $doc_dir_num > 0; 
     644       my $pattern = '^(.{1,' . $self->{'subdir_split_length'} . '})'; 
     645       if ($self->{'subdir_hash_prefix'}) 
     646       { 
     647         $pattern = '^((HASH)?.{1,' . $self->{'subdir_split_length'} . '})'; 
     648       } 
     649       #if ($doc_dir_rest =~ s/^(.{1,$limit})//) { 
     650       if ($doc_dir_rest =~ s/$pattern//i) 
     651       { 
     652       $doc_dir .= $1; 
     653       $doc_dir_num++; 
     654       } 
     655   } while ($doc_dir_rest ne "" &&  
     656        ((-d &FileUtils::filenameConcatenate($working_dir, "$doc_dir.dir")) ||  
     657         ($working_info->size() >= 1024 && $doc_dir_num < 2))); 
     658   my $i = 1; 
     659   my $doc_dir_base = $doc_dir; 
     660   while (-d &FileUtils::filenameConcatenate($working_dir, "$doc_dir.dir")) { 
     661       $doc_dir = "$doc_dir_base-$i"; 
     662       $i++; 
     663   } 
     664           
     665   return "$doc_dir.dir"; 
     666} 
     667 
    625668## @function get_new_doc_dir() 
    626669# 
     
    675718      $doc_dir .= $1; 
    676719      $doc_dir_num++; 
    677       $created_directory = &FileUtils::makeAllDirectories(&FileUtils::filenameConcatenate($working_dir, $doc_dir . '.dir')); 
    678     } 
    679     my $new_dir = &FileUtils::filenameConcatenate($working_dir, $doc_dir . '.dir'); 
     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'); 
    680727    ###rint STDERR "[DEBUG] BasePlugout::get_new_doc_dir(<working_info>, $working_dir, $oid)\n"; 
    681728    ###rint STDERR " - create directory: $new_dir => $created_directory\n";