]> git.treefish.org Git - fex.git/blobdiff - bin/fex_cleanup
Original release 20160919
[fex.git] / bin / fex_cleanup
index 1d87dcfe9e59cfc861cd6767f22fb3ce836d84e1..1f38d6b42b5bc975b692e76d026a09afacf8779b 100755 (executable)
@@ -41,7 +41,8 @@ our ($FEXHOME);
 our ($spooldir,@logdir,$docdir);
 our ($akeydir,$ukeydir,$dkeydir,$skeydir,$gkeydir,$xkeydir,$lockdir);
 our ($durl,$debug,$autodelete,$hostname,$admin,$admin_pw,$bcc);
-$keep_default = 5;
+our $keep_default = 5;
+our $purge = $keep_default*3;
 
 # load common code, local config : $HOME/lib/fex.ph
 require "$FEXLIB/fex.pp" or die "$0: cannot load $FEXLIB/fex.pp - $!\n";
@@ -418,8 +419,9 @@ exit;
 sub cleanup {
   my ($to,$from,$file) = @_;
   my ($data,$download,$notify,$mtime,$warn,$dir,$filename,$dkey,$delay);
-  my $comment = '';
   my $keep = $keep_default;
+  my $purge = $::purge || 3*$keep;
+  my $comment = '';
   my $kf = "$to/$from/$file/keep";
   my $ef = "$to/$from/$file/error";
   local $_;
@@ -440,8 +442,9 @@ sub cleanup {
         logdel($file,"$file deleted");
       }
     } elsif ($mtime = lmtime("$file/error")) {
-      if ($today > 3*$keep*DS+$mtime) {
-        verbose("rmrf $file (today=$today mtime_error=$mtime keep=$keep)");
+      $purge = $1*$keep if $purge =~ /(\d+).*keep/;
+      if ($today > $purge*DS+$mtime) {
+        verbose("rmrf $file (today=$today mtime_error=$mtime keep=$keep purge=$purge)");
         logdel($file,"$file deleted");
       }
     } else {