brooklynBen has asked for the wisdom of the Perl Monks concerning the following question:
I've been using a server side script for about 5 years now. The idea is to mirror the contents of the requested directory. These directories are very, very active; at any time files are being created, modified, deleted and renamed. I can have as few as a dozen to as many as fifty-thousand files. At any moment in time I cannot predict what if anything will happen much less to which file(s) it will happen to.
This whole process works 98% of the time except for when (I think) a file is renamed between the time I call $zip->addFile and then $zip->writeToFileNamed. The program dies.
I'm not all that concern that I get a perfect mirror it's just supposed to be a snapshot so if my mirror leaves out a file or two it won't matter a whole lot. Is there a way to tell Archive to skip a file if it no longer exists?
use Archive::Zip qw( :ERROR_CODES ); my $zip = Archive::Zip->new(); opendir(DataDir, "."); foreach (readdir(DataDir)) { if( -e $_ and $_ ne "." and $_ ne "..") { $member = $zip->addFile($_); $member->desiredCompressionLevel( 1 ); } } $zip->writeToFileNamed("myFile.zip");
Edit: I forgot to mention that I'm running this on a Windows Server 2003 with ActivePerl
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Archive::Zip[ing] a very active directory
by jfroebe (Parson) on Oct 11, 2010 at 20:43 UTC | |
by Marshall (Canon) on Oct 12, 2010 at 21:12 UTC |