Changeset 28066

Show
Ignore:
Timestamp:
15.08.2013 16:42:23 (6 years ago)
Author:
ak19
Message:

Dr Bainbridge fixed a subtle bug where the timestamped tmp folders generated weren't as unique as they were intended to be because the tmp folders get deleted after a document has been converted to html, so the next timestamped tmp folder generated can be the same because a clash with an existing timestamped folder wasn't detected (since it had already been deleted). This will help with getting diffcol to succeed in the Multimedia tutorial collection.

Files:
1 modified

Legend:

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

    r27970 r28066  
    226226} 
    227227 
     228# These 2 are "static" variables used by the get_timestamped_tmp_folder() subroutine below and 
     229# belong with that function. They help ensure the timestamped tmp folders generated are unique. 
     230my $previous_timestamp = undef; 
     231my $previous_timestamp_f = 0; # frequency 
     232 
    228233sub get_timestamped_tmp_folder 
    229234{ 
    230  
     235     
    231236    my $tmp_dirname; 
    232237    if(defined $ENV{'GSDLCOLLECTDIR'}) { 
     
    243248    # add the timestamp into the path otherwise we can run into problems  
    244249    # if documents have the same name 
    245     my $timestamp = time; 
     250    my $timestamp = time;    
     251     
     252    if (!defined $previous_timestamp || ($timestamp > $previous_timestamp)) { 
     253        $previous_timestamp_f = 0; 
     254        $previous_timestamp = $timestamp; 
     255    } else { 
     256        $previous_timestamp_f++; 
     257    }  
     258     
    246259    my $time_tmp_dirname = &FileUtils::filenameConcatenate($tmp_dirname, $timestamp); 
    247     $tmp_dirname = $time_tmp_dirname; 
    248     my $i = 1; 
     260    $tmp_dirname = $time_tmp_dirname;    
     261    my $i = $previous_timestamp_f; 
     262     
     263    if($previous_timestamp_f > 0) { 
     264        $tmp_dirname = $time_tmp_dirname."_".$i; 
     265        $i++; 
     266    } 
    249267    while (-e $tmp_dirname) { 
    250     $tmp_dirname = "$time_tmp_dirname$i"; 
     268    $tmp_dirname = $time_tmp_dirname."_".$i; 
    251269    $i++; 
    252270    } 
    253     &FileUtils::makeDirectory($tmp_dirname); 
    254   
     271    &FileUtils::makeDirectory($tmp_dirname);  
     272 
    255273    return $tmp_dirname; 
    256274}