Changeset 32779

Show
Ignore:
Timestamp:
16.02.2019 19:36:06 (6 months ago)
Author:
ak19
Message:

1. Bugfix to wget downloading: call to quotewords() necessarily has 2nd parameter keep set to to false/0, in order to remove quotes from cmd args, but which also has the undesirable side-effect of removing single backslashes (while double backslashes get turned to single backslashes). This caused a bug in the download tutorial failing as the cache dir on windows, which contained backslashes going in, ended up containing no backslashes at all when wget was run. The correct place to fix it is before quotewords() gets called in WgetDownload?'s 2 UseWget?() methods. Before quotewords() is called, singlebackslashes are now protected as double backslashes, so that quotewords with 2nd param keep=0 now gets things back to normal by turning double backslashes to single again. 2. Minor change to MediaWikiDownload? to reuse variable.

Location:
main/trunk/greenstone2/perllib/downloaders
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/downloaders/MediaWikiDownload.pm

    r28250 r32779  
    114114    # Setup the command for using wget 
    115115    $wget_options = "-N -k -x -t 2 -P \"". $hashGeneralOptions->{"cache_dir"}."\" $strWgetOptions $strOptions "; 
    116     my $cmdWget = "-N -k -x -t 2 -P \"". $hashGeneralOptions->{"cache_dir"}."\" $strWgetOptions $strOptions " . $self->{'url'}; 
     116    my $cmdWget   = $wget_options . $self->{'url'}; 
    117117     
    118118    # Download the web pages 
  • main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm

    r31975 r32779  
    374374    $cmdWget =~ s/\s+$//; 
    375375 
     376    # replace backslashes with double backslashes, so that we preserve backslash after doing quotewords() step below with its necessary 2nd param keep=0 
     377    $cmdWget =~ s@\\@\\\\@g; 
     378     
    376379    # split on "words" 
    377380    #my @commandargs = split(' ', $cmdWget); 
     
    381384    my @commandargs = quotewords('\s+', 0, $cmdWget); 
    382385    unshift(@commandargs, $wget_file_path); # prepend the wget cmd 
    383     #print STDERR "Command is: ".join(",", @commandargs) . "\n"; # goes into ServerInfoDialog 
     386    print STDOUT "Command is: ".join(",", @commandargs) . "\n"; # if STDERR, cmd will go into ServerInfoDialog 
    384387     
    385388    # Wget's output needs to be monitored to find out when it has naturally terminated. 
     
    651654    $cmdWget =~ s/^\s+//; 
    652655    $cmdWget =~ s/\s+$//; 
     656     
     657    # replace backslashes with double backslashes, so that we preserve backslash after doing quotewords() step below with its necessary 2nd param keep=0 
     658    $cmdWget =~ s@\\@\\\\@g; 
     659     
    653660    my @commandargs = quotewords('\s+', 0, $cmdWget); 
    654661    unshift(@commandargs, $wget_file_path); # prepend wget cmd to the command array