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


In reply to Archive::Zip[ing] a very active directory by brooklynBen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.