Author: toad
Date: 2006-12-08 18:10:15 +0000 (Fri, 08 Dec 2006)
New Revision: 11303

Modified:
   trunk/freenet/src/freenet/support/io/FilenameGenerator.java
Log:
Wiping old temp files can take a long time, tell the user what's happened when 
we've finished.
Also tell the user if we can't delete any file.

Modified: trunk/freenet/src/freenet/support/io/FilenameGenerator.java
===================================================================
--- trunk/freenet/src/freenet/support/io/FilenameGenerator.java 2006-12-08 
16:29:12 UTC (rev 11302)
+++ trunk/freenet/src/freenet/support/io/FilenameGenerator.java 2006-12-08 
18:10:15 UTC (rev 11303)
@@ -6,6 +6,7 @@
 import freenet.crypt.RandomSource;
 import freenet.support.HexUtil;
 import freenet.support.Logger;
+import freenet.support.TimeUtil;

 public class FilenameGenerator {

@@ -34,6 +35,8 @@
                        throw new IOException("Not a directory or cannot 
read/write: "+tmpDir);

                if(wipeFiles) {
+                       long wipedFiles = 0;
+                       long startWipe = System.currentTimeMillis();
                        File[] filenames = tmpDir.listFiles();
                        if(filenames != null) {
                                for(int i=0;i<filenames.length;i++) {
@@ -41,10 +44,14 @@
                                        String name = f.getName();
                                        if((((File.separatorChar == '\\') && 
name.toLowerCase().startsWith(prefix.toLowerCase())) ||
                                                        
name.startsWith(prefix))) {
-                                               f.delete();
+                                               wipedFiles++;
+                                               if(!f.delete() && f.exists())
+                                                       
System.err.println("Unable to delete temporary file "+f+" - permissions 
problem?");
                                        }
                                }
                        }
+                       long endWipe = System.currentTimeMillis();
+                       System.err.println("Deleted "+wipedFiles+" temporary 
files in "+TimeUtil.formatTime(endWipe-startWipe));
                }
        }



Reply via email to