Ignore:
Timestamp:
2023-12-06T22:23:05+13:00 (5 months ago)
Author:
anupama
Message:

Related to the previous 2 commits. Removed or commented out most debug statements, only one remains (the final filepath within the cache dir for a file that has been determined by the new subroutine). Adjusted the new subroutine's description.

File:
1 edited

Legend:

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

    r38477 r38478  
    7676
    7777
    78 # given the file location where media or other product files are generated
    79 # (such as the pages of a PDF file converted to paged images), this returns
    80 # the full path to the document's cache subdirectory they are to be stored
    81 # e.g. collect/<collection>/cached>/<fileRootname>
     78# This method exists to prevent duplication of long filepaths within the cache dir.
     79# Given the file location where media or other product files to be cached are generated
     80# (such as the pages of a PDF file converted to paged images), this subroutine returns
     81# the relative path the document is to be stored as, within the cache subdirectory.
     82# e.g. collect/<collection>/cached/<fileroot/numbered-filename.ext>
     83# will return fileroot/numbered-filename.ext
     84# e.g.#2 collect/<collection>/import/<fileroot.ext> will return fileroot.ext
    8285sub get_cache_filename_for_location
    8386{
     
    114117    # reverse sort as we want to try matching more specific "$coll_dir/$subdir" before $coll_dir
    115118   
    116     print STDERR "@@@ Key and value: $key\n\t $prefixre_to_replacere_map{$key}\n";
     119    #print STDERR "@@@ Key and value: $key\n\t $prefixre_to_replacere_map{$key}\n";
    117120
    118121    my $prefixre = $key;
     
    121124    ($file) = ($filename =~ m/$prefixre/);
    122125    if (!defined $file || $file eq $filename) {
    123         print STDERR "\t#### No match\n"; # keep looping looking for the next match
     126        #print STDERR "\t#### No match\n"; # keep looping looking for the next match
     127        next;
    124128    } else {
    125         print STDERR "\t#### Found match. Applying: $replacere\n";
     129        #print STDERR "\t#### Found match. Applying: $replacere\n";
    126130        if($replacere eq $orig_file_root_replacere) {
    127131        $file = $orig_file_root_replacere.$file if $file;
     
    140144    $file =~ s/^\/|\\//; # get rid of leading slash from relative filename
    141145    $file =~ s@^(\.(\/|\/))*@@; # get rid of any ./ at the start
    142     print STDERR "\tXXXX final file is: $file\n";
     146    print STDERR "\t@@@ Final cache tail file is: $file\n";
    143147
    144148    return $file
     
    160164    $filename =~ s/\\/\//g;
    161165    $base_dir =~ s/\\/\//g;
    162     print STDERR "@@@@ col_dir    : $collect_dir\n";
    163     print STDERR "@@@@ filename: $filename\n";
    164 
     166   
    165167    my $file = $self->get_cache_filename_for_location($filename, $orig_file_root, $base_dir, $collect_dir);
    166168
     
    180182
    181183    my $base_output_dir = &FileUtils::filenameConcatenate($collect_dir,"cached",$dirname);
    182 ##    my $base_output_dir = &FileUtils::filenameConcatenate($collect_dir,"cached",$dirname);
    183184
    184185    if (!-e $base_output_dir ) {
     
    190191
    191192
    192     print STDERR "@@@@ base_output_dir: $base_output_dir\n";
    193     print STDERR "@@@@ file_root: $file_root\n";
     193    #print STDERR "@@@@ base_output_dir: $base_output_dir\n";
     194    #print STDERR "@@@@ file_root: $file_root\n";
    194195
    195196    my $output_dir = &FileUtils::filenameConcatenate($base_output_dir,$file_root);
Note: See TracChangeset for help on using the changeset viewer.