The rearguard idea is appealing.

The extractions currently use Archive::Unzip::Burst as the first attempt. I don't know its behaviour, but I assume that if some files exist and are locked then it will fail. In that event the approach switches to iterating over $zip->memberNames, so it will still work. (Actually, Archive::Unzip::Burst seems not to install on Windows, so the latter approach will be the norm on that OS).

Of course, this won't fix the issues where files are cleaned up while a PAR is running process, so some sort of API sub would still be useful to allow scripts to re-extract if file opens fail. This would not be simple to apply where file opens are called deep inside third party modules, but will still benefit the simpler cases.


WRT the different cache areas, PAR::_extract_inc currently spends up to 10 seconds trying to create a lock file, so that line needs to be modified. Adding a check for -w on the target temp location should be enough to avoid that when the exe file is in a non-writable directory.

Apart from possible security issues, this approach could also lead to multiple par temp folders which could confuse users. Of course, being "up front" about files could be a useful thing to do.


Regards,
Shawn.


On 18/12/2014 19:02, Roderich Schupp wrote:
Here are two other ideas for a workaround for "some cleanup program purged some files in my cache area".
The rearguard hack:

  * make sure extracted files get the timestamp of extraction, not the
    timestamp recorded in the zip archive
  * add a dummy file, say REARGUARD.txt, at the top of the cache area
  * extract it as the first file (so that it becomes the oldest
    extracted file)
  * at packed executable startup, check that REARGUARD.txt exists,
    otherwise re-extract all files

Different location for the cache area:

  * when the packed executable foo.exe is installed as
    /some/path/foo.exe, extract to /some/path/foo.unpacked if this
    directory can be created
  * otherwise fall back to current behaviour, ie. extract to $TMP/par-USER
  * I'm not sure about the security implications

Cheers, Roderich

--
Assoc Prof Shawn Laffan
  School of Biological, Earth and Environmental Sciences
  UNSW, Sydney 2052, Australia
  Tel +61 2 9385 8093   Fax +61 2 9385 1558
  http://www.bees.unsw.edu.au/staff/shawn-laffan
  http://www.purl.org/biodiverse (free diversity analysis software)
  http://www.tandf.co.uk/journals/ijgis

  UNSW CRICOS Provider Code 00098G

Reply via email to