View Full Version : [REQ] On the Fly Archiving Script
Scuttle
04-14-2004, 01:55 PM
Ok, some unix-based sites I have been on has had the ability to archive and send a selected directory on the fly, you send "RETR foldername.zip" for example, and the server will send you a file with the folder 'foldername' all zipped up.
Or as one site puts it in one of their welcome-messages:
It is also possible to tar and eventually compress or gzip a
directory structure by adding .tar, .tar.Z or .tar.gz to the directory-name.
For example, the directory structure (including the files) under
/pub/gnu/gimp can be retrived as a single tar file using the command
'get gimp.tar' (obviously you'll have to 'cd /pub/gnu/' first).
If you you want a compressed tar file, simply use 'get gimp.tar.Z'
What would the easiest way to accomplish this with ioFTPD?
mr_F_2
04-14-2004, 04:26 PM
on pre RETR, run a script to see if the file exists that is requested, if not (but the directory with the same name minus the extention exists) then tar it up and send it off?
something would have to be trigged to del the tarball after the file is downloaded
Scuttle
04-14-2004, 05:04 PM
Originally posted by mr_F
on pre RETR, run a script to see if the file exists that is requested, if not (but the directory with the same name minus the extention exists) then tar it up and send it off?
something would have to be trigged to del the tarball after the file is downloaded
Hmm, this looks like an excellent place to start. I checked ioftpd.ini and found [FTP_Pre-Command_Events]. The RETR-command was not entered here (using a basic installation). Can I just add "RETR = my-bat-file.bat" here?
Also, I take it I could use another bat-file on the OnDownloadComplete-event and delete the file?
ADDiCT
04-15-2004, 01:10 AM
be aware of this problem:
/abc/
-> no abc.zip exists
RETR abc.zip
-> /abc/ gets zipped into abc.zip
Now u have a file /abc/abc.zip or /abc.zip
(not sure where u want to see the file placed).
After the file has been sent, how do u determine if the file existed before the RETR command?
Timestamp? might be innacurate if it's a large dir and a slow transfer...
Scuttle
04-15-2004, 07:34 AM
If the file does not exist, i.e you are making an on the fly zip, you create a file somewhere else named folder.zip-MARKER, then after the transfer is done you check for this file, and if it exists, delete the zip and the marker-file.
Mouton
04-15-2004, 10:40 AM
If the client sends RETR somefile.ext, you NEED a file somefile.ext in the current dir or ioFTPD won't be able to send it. You can't tell io to send some other file instead of the one asked in the RETR command.
CWD /
RETR somedir.zip
-> PRE RETR = ..\scripts\zipitup.bat gets called with RETR somedir.zip in parameter
-> produce a somedir.zip file in /
File is transfered
-> OnDownloadComplete = ..\scripts\cleanit.bat gets called with the filename in parameter
-> deletes the file
Same should be done OnDownloadFailed, in case the person doesn't retry the transfer. You would be left with a .zip on your /...
Scuttle
04-15-2004, 10:48 AM
Yes, all this I am clear about, but if the person is downloading an already existing zip-file I need some way to tell. In the pre-command script I create a file named somedir.zip-DYNAMIC if the user download a created zip, then in the OnDownloadComplete script I check for the flag-file, if it exists, delete the zip, if it doesn't, don't
Mouton
04-15-2004, 11:18 AM
Would work indeed.
Hope u got some good batch-files know-how. This isn't an easy one.
vBulletin® v3.8.11 Alpha 3, Copyright ©2000-2024, vBulletin Solutions, Inc.