Forum OpenACS Development: New util::zip_file command

Collapse
Posted by Antonio Pisano on
Out of curiosity raised after post here http://www.openacs.org/forums/message-view?message_id=4189731, I've found out we had a bit of direct bash invocation here:

/packages/file-storage/www/download-zip.tcl

This is unconvenient for a software which is meant to work on both windows and linux. Also, I've found myself to recurr to similar hacks in the past because we didn't have an official way of creating zip files programmatically.

For this reason I've added util::zip_file command, in which I handle differences in command invocation between linux and windows.

I've tested my changes against the "download folder as zip file" feature in file-storage on my unix development installation. Unfortunately I don't have a Windows installation to test on, but maybe Maurizio Martignano or people from SpazioIT could report eventual bugs.

The presence of the zip utility on the system is still a requirement.

Best regards

Collapse
Posted by Antonio Pisano on
To complete the round trip, I've added an util::unzip_file command.
Collapse
Posted by Antonio Pisano on
I've now shortened the name of the two procedures in util::zip and util::unzip
Collapse
Posted by Gustaf Neumann on
thanks, antonio. The code looks fine! Do you know, what are the version dependencies are (does it need a minimal version version of zip or unzip to function?).

You are mentioning "windows and linux". i guess, you did not want to imply that it only works on these two and not on e.g. Mac OS X or Solaris. If this is part of the core, it is supposed to work everywhere, so it is necessary to include zip/unzip to the dependencies in the installer scripts.

We are using on our production platform mostly nx::zip [1], which allows e.g. to stream zip-files (e.g. from the content repository) without copying. Without that we had the problem with the direct use of zip that voluminous file-system operations could bring the fastest server to a crawl.

[1] https://github.com/gustafn/nsf/blob/master/library/lib/nx-zip.tcl

Collapse
Posted by Antonio Pisano on
Well, the utility actually implies the presence of the bash shell on every platform different from Windows... Mac OS should not be a problem, but I cannot speak about Solaris...

I haven't checked throughly about zip command compatibility, because I assumed the options I've used would be there in every current zip tool one could download.

This said, your concerns are legit. The main problem is that we are wrapping a command here, and that this command lacks a feature so basic we have to build a little script every time... very unconvenient.

Didn't know about nx::zip. It would be far better of course! Maybe I could use the same trick we did on util::http and check for the platform: if Naviserver -> nx::zip, otherwise the command hack.

Collapse
Posted by Gustaf Neumann on
i was more concerned about (a) the availability of the zip+unzip programs on various systems (who cares, it get installed) and (b) about the version dependencies (are the sematics and flgs of zip / unzip identical over all versions)) and (c) for the further consequences (installer scripts, debian). Such things then to become forgotten.