Changeset 31477

Show
Ignore:
Timestamp:
09.03.2017 14:32:44 (3 years ago)
Author:
kjdon
Message:

blocking moved to EncodingUtil?. debug stuff still in here. needs tidying up

Files:
1 modified

Legend:

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

    r31459 r31477  
    238238        foreach my $e (keys %$exts) { 
    239239        # block the file 
    240         &util::block_filename($block_hash,"$prefix$e"); 
     240        $self->block_filename($block_hash,"$prefix$e"); 
    241241        # set up as an associatd file 
    242242        print STDERR "  $self->{'plugin_type'}: Associating $prefix$e with $tie_to version\n"; 
     
    254254 
    255255 
    256 # do block exp OR special blocking ??? 
    257  
    258 sub file_is_blocked { 
    259     my $self = shift (@_); 
    260     my ($block_hash, $filename_full_path) = @_; 
    261  
    262     $filename_full_path = &util::upgrade_if_dos_filename($filename_full_path); 
    263  
    264     if (($ENV{'GSDLOS'} =~ m/^windows$/) && ($^O ne "cygwin")) { 
    265     # on windows, all block paths are lowercased. 
    266     my $lower_filename = lc ($filename_full_path); 
    267     if (defined $block_hash->{'file_blocks'}->{$lower_filename}) { 
    268         $self->{'num_blocked'} ++; 
    269         return 1; 
    270     } 
    271     } 
    272     else { 
    273     if (defined $block_hash->{'file_blocks'}->{$filename_full_path}) { 
    274         $self->{'num_blocked'} ++; 
    275         return 1; 
    276     } 
    277     } 
    278     # check Directory plugin's own block_exp  
    279     if ($self->{'block_exp'} ne "" && $filename_full_path =~ /$self->{'block_exp'}/) { 
    280     $self->{'num_blocked'} ++; 
    281     return 1; # blocked 
    282     } 
    283     return 0; 
    284 } 
    285  
    286256 
    287257 
     
    334304 
    335305    # Recursively read each $raw_subfile 
    336     print $outhandle "DirectoryPlugin block recurring: ". Encode::decode("utf8", $raw_file_subfile) ."\n" if ($verbosity > 2); 
    337     print $outhandle "DirectoryPlugin block recurring: ". Encode::decode(locale =>$raw_file_subfile) ."\n" if ($verbosity > 2); 
    338      
     306    print $outhandle "DirectoryPlugin block recurring: $raw_file_subfile\n" if ($verbosity > 2); 
    339307    #$count += &plugin::file_block_read ($pluginfo, $this_file_base_dir, 
    340308 
     
    434402    # but with URL style slashes.  
    435403    my $local_dirname = &util::filename_within_directory_url_format($dirname, $base_dir); 
    436     ### need it in perl unicode, not raw filesystem 
    437     my $filename_encoding =  $self->guess_filesystem_encoding();   
    438          
    439     # copied this from set_Source_metadata in BasePlugin 
    440     if ((defined $filename_encoding) && ($filename_encoding ne "ascii")) { 
    441     # Use filename_encoding to map raw filename to a Perl unicode-aware string  
    442     $local_dirname = decode($filename_encoding,$local_dirname);      
    443     } 
    444     else { 
    445     # otherwise generate %xx encoded version of filename for char > 127 
    446     $local_dirname = &unicode::raw_filename_to_url_encoded($local_dirname); 
    447     } 
    448404 
    449405    # if we are in import folder, then local_dirname will be empty 
    450406    if ($local_dirname ne "") { 
     407    # convert to perl unicode 
     408    $local_dirname = $self->raw_filename_to_unicode($local_dirname); 
     409     
    451410    # look for extra metadata passed down from higher folders    
    452411    $local_dirname .= "/"; # closing slash must be URL type slash also and not $dirsep; 
     
    476435    my $raw_file_subfile = &FileUtils::filenameConcatenate($file, $raw_subfile); 
    477436    my $raw_full_filename = &FileUtils::filenameConcatenate($this_file_base_dir, $raw_file_subfile); 
    478  
    479     if ($self->file_is_blocked($block_hash,$raw_full_filename)) { 
    480         print STDERR "DirectoryPlugin: file $raw_full_filename was blocked for metadata_read\n" if ($verbosity > 2); 
     437    if ($self->raw_file_is_blocked($block_hash, $raw_full_filename)) { 
     438        print STDERR "DirectoryPlugin: file $raw_full_filename was blocked for metadata_read\n";# if ($verbosity > 2); 
     439        print STDERR "raw file was blocked for metadata read\n"; 
     440        print STDERR &unicode::debug_unicode_string($raw_full_filename)."\n"; 
    481441        next; 
    482442    } 
    483      
     443 
    484444    # Recursively read each $raw_subfile 
    485     print $outhandle "DirectoryPlugin metadata recurring: $raw_subfile\n" if ($verbosity > 2); 
     445    print $outhandle "DirectoryPlugin metadata recurring: $raw_subfile\n"; # if ($verbosity > 2); 
    486446     
    487447    &plugin::metadata_read ($pluginfo, $this_file_base_dir, 
     
    560520    my $raw_full_filename  
    561521        = &FileUtils::filenameConcatenate($this_file_base_dir,$raw_file_subfile); 
    562  
     522    my $full_unicode_file = $self->raw_filename_to_unicode($raw_full_filename); 
     523    print STDERR "full unicode filename $full_unicode_file\n"; 
     524    print STDERR &unicode::debug_unicode_string($full_unicode_file)."\n"; 
     525    if ($self->file_is_blocked($block_hash,$full_unicode_file)) { 
     526        print STDERR "Actually, we have blocked the unicode version\n"; 
     527        next; 
     528    } 
    563529    if ($self->file_is_blocked($block_hash,$raw_full_filename)) { 
    564         print STDERR "DirectoryPlugin: file $raw_full_filename was blocked for read\n" if ($verbosity > 2); 
     530        print STDERR "DirectoryPlugin: file $raw_full_filename was blocked for read\n"; # if ($verbosity > 2); 
    565531        next; 
    566532    } 
    567  
    568533    # Follow Windows shortcuts 
    569534    if ($raw_subfile =~ m/(?i)\.lnk$/ && (($ENV{'GSDLOS'} =~ m/^windows$/i) && ($^O ne "cygwin"))) {