Show
Ignore:
Timestamp:
22.03.2016 16:21:47 (4 years ago)
Author:
davidb
Message:

Technique for working out cached-dir name for file updated to allow it to work in the situation where sub-directories are used within the original 'import; folder

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/BaseMediaConverter.pm

    r27982 r30427  
    8888    $collect_dir =~ s/\\/\//g; # Work in Unix style world 
    8989     
    90 ##    print STDERR "**** base_dir = ", $base_dir, "\n"; 
    91   
    9290    # Work out relative filename within 'base_dir' 
    9391    $filename =~ s/\\/\//g; 
    94     $base_dir =~ s/\\/\//g; 
     92    $base_dir =~ s/\\/\//g; 
    9593    my ($file) = ($filename =~ m/^$base_dir(.*?)$/); 
    9694     
    9795    if (!defined $file) { 
    9896    # Perhaps the filename is taken from within cache_dir area? 
    99     my $prev_cached_dir = $self->{'cached_dir'}; 
    100     ($file) = ($filename =~ m/^$prev_cached_dir(.*?)$/); 
     97    my $cached_dir = &FileUtils::filenameConcatenate($collect_dir,"cached"); 
     98    ($file) = ($filename =~ m/^$cached_dir(.*?)$/); 
     99    # A cached name already has the fileroot baked -in as the last directory name 
     100    # => strip it out 
     101    $file =~ s/[\/\\][^\/\\]+([\/\\][^\/\\]*)$/$1/; 
     102 
     103#       Commented out code is the previous version that looked to 
     104#       handle this situation, but ran foul of situtation where 
     105#       sub-directories within 'import' are used 
     106# 
     107#   # Perhaps the filename is taken from within cache_dir area? 
     108#   my $prev_cached_dir = $self->{'cached_dir'}; 
     109#   ($file) = ($filename =~ m/^$prev_cached_dir(.*?)$/); 
    101110    } 
    102111 
     
    108117    my ($file_root, $dirname, $suffix) 
    109118    = &File::Basename::fileparse($file, "\\.[^\\.]+\$"); 
    110  
    111119 
    112120    # if dirname is in collections tmp area, remove collect_dir prefix 
     
    119127 
    120128    my $base_output_dir = &FileUtils::filenameConcatenate($collect_dir,"cached",$dirname); 
     129##    my $base_output_dir = &FileUtils::filenameConcatenate($collect_dir,"cached",$dirname); 
    121130 
    122131    if (!-e $base_output_dir ) {