http://qs321.pair.com?node_id=11116751


in reply to Re: saveResources_future and tab in WWW::Mechanize::Chrome
in thread saveResources_future and tab in WWW::Mechanize::Chrome

Dear Corion,
I only tested the code from the documentation (exactly as written above). And 'this_page.html' and all files will be placed in the working directory. I can change target_file location and save somewehere else but whatever location I use for target_dir, all files are always saved in the working directory.
I am still using WWW::Mechanize::Firefox and would like to migrate to Chrome. Just for your information, I was not able to install WWW::Mechanize::Chrome with ActiveState Perl running despite your advice to force the installation of Imager::File::PNG if screenshots are not necessary. I tried to force the installation of Imager::File::PNG as well as WWW::Mechanize::Chrome using cpanm but it did not work. Now I am using Strawberry Perl
Best regards
1nelly1

Replies are listed 'Best First'.
Re^3: saveResources_future and tab in WWW::Mechanize::Chrome
by Corion (Patriarch) on May 13, 2020 at 12:04 UTC

    Thank you for making me revisit my assumptions!

    Indeed, the parameter for specifying the download directory was never used. This will be fixed in the next release of WWW::Mechanize::Chrome, which I will likely release this evening.

      Thank you! I think it was here:
      $names{ $resource->{url} } ||= File::Spec->catfile( $target_dir, $names{ $resource->{url} });
      Best regards
      1nelly1

        No, that's the part that works.

        The part that fails is in ub fetchResources_future, which doesn't respect any base directory at all currently. There, more or less the same thing has to happen:

        ... my $duplicates; my $old_target = $target; while( $filenames{ $target }) { $duplicates++; ( $target = $old_target )=~ s!\.(\w+)$!_$duplicates.$ +1!; }; - $names->{ $res->{url} } = $target; + $names->{ $res->{url} } = File::Spec->catfile( $base_dir, + $target ); };