Changeset 23544 for main


Ignore:
Timestamp:
2011-01-10T15:07:51+13:00 (13 years ago)
Author:
kjdon
Message:

on windows, if have a .JPG cover image, then a -e xxx.jpg test works, but if that filename is put into the block list, it won't match later on the .JPG, and the file won't be blocked. Solution, lowercase entirefilepath before adding into or checking in the block_hash->file_blocks list. but only for windows. Now don't need the alternative A: a: options for drive letters.

Location:
main/trunk/greenstone2/perllib/plugins
Files:
2 edited

Legend:

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

    r23484 r23544  
    389389    if ($ENV{'GSDLOS'} =~ m/^windows$/) {
    390390   
    391     my $lower_drive = $filename;
    392     $lower_drive =~ s/^([A-Z]):/\l$1:/i;
     391    # lower case the entire thing, eg for cover.jpg when its actually cover.JPG
     392    my $lower_filename = lc($filename);
     393    $block_hash->{'file_blocks'}->{$lower_filename} = 1;
     394#   my $lower_drive = $filename;
     395#   $lower_drive =~ s/^([A-Z]):/\l$1:/i;
    393396   
    394     my $upper_drive = $filename;
    395     $upper_drive =~ s/^([A-Z]):/\u$1:/i;
    396    
    397     $block_hash->{'file_blocks'}->{$lower_drive} = 1;
    398     $block_hash->{'file_blocks'}->{$upper_drive} = 1;       
     397#   my $upper_drive = $filename;
     398#   $upper_drive =~ s/^([A-Z]):/\u$1:/i;
     399#   
     400#   $block_hash->{'file_blocks'}->{$lower_drive} = 1;
     401#   $block_hash->{'file_blocks'}->{$upper_drive} = 1;       
    399402    }
    400403    else {
  • main/trunk/greenstone2/perllib/plugins/DirectoryPlugin.pm

    r23419 r23544  
    260260###    print STDERR "*** DirectoryPlugin::file_is_blocked $filename_full_path\n";
    261261
    262     if (defined $block_hash->{'file_blocks'}->{$filename_full_path}) {
    263     $self->{'num_blocked'} ++;
    264     return 1;
     262    if ($ENV{'GSDLOS'} =~ m/^windows$/) {
     263    # on windows, all block paths are lowercased.
     264    my $lower_filename = lc ($filename_full_path);
     265    if (defined $block_hash->{'file_blocks'}->{$lower_filename}) {
     266        $self->{'num_blocked'} ++;
     267        return 1;
     268    }
     269    }
     270    else {
     271    if (defined $block_hash->{'file_blocks'}->{$filename_full_path}) {
     272        $self->{'num_blocked'} ++;
     273        return 1;
     274    }
    265275    }
    266276    # check Directory plugin's own block_exp
Note: See TracChangeset for help on using the changeset viewer.