Author: nextgens
Date: 2008-07-18 16:40:57 +0000 (Fri, 18 Jul 2008)
New Revision: 21213

Modified:
   trunk/freenet/src/freenet/support/io/PersistentTempBucketFactory.java
Log:
Same thing in PersistentTempBucketFactory

Modified: trunk/freenet/src/freenet/support/io/PersistentTempBucketFactory.java
===================================================================
--- trunk/freenet/src/freenet/support/io/PersistentTempBucketFactory.java       
2008-07-18 16:31:35 UTC (rev 21212)
+++ trunk/freenet/src/freenet/support/io/PersistentTempBucketFactory.java       
2008-07-18 16:40:57 UTC (rev 21213)
@@ -13,6 +13,7 @@
 import freenet.support.Logger;
 import freenet.support.api.Bucket;
 import freenet.support.api.BucketFactory;
+import java.io.FileFilter;
 import java.util.Random;

 /**
@@ -42,7 +43,7 @@
        /** Buckets to free */
        private LinkedList bucketsToFree;

-       public PersistentTempBucketFactory(File dir, String prefix, 
RandomSource strongPRNG, Random weakPRNG) throws IOException {
+       public PersistentTempBucketFactory(File dir, final String prefix, 
RandomSource strongPRNG, Random weakPRNG) throws IOException {
                boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
                this.dir = dir;
                this.strongPRNG = strongPRNG;
@@ -57,24 +58,24 @@
                if(!dir.isDirectory())
                        throw new IOException("Directory is not a directory: 
"+dir);
                originalFiles = new HashSet();
-               File[] files = dir.listFiles();
-               if((files != null) && (files.length > 0)) {
-                       for(int i=0;i<files.length;i++) {
-                               File f = files[i];
-                               String name = f.getName();
-                               if(f.isDirectory()) continue;
-                               if(!f.exists()) continue;
-                               if(!name.startsWith(prefix)) {
-                               if(Logger.shouldLog(Logger.MINOR, this))
-                                       Logger.minor(this, "Ignoring "+name);
-                                       continue;
-                               }
-                               f = FileUtil.getCanonicalFile(f);
-                               if(logMINOR)
-                                       Logger.minor(this, "Found "+f);
-                               originalFiles.add(f);
+               File[] files = dir.listFiles(new FileFilter() {
+
+                       public boolean accept(File pathname) {
+                               if(!pathname.exists() || pathname.isDirectory())
+                                       return false;
+                               String name = pathname.getName();
+                               if(name.startsWith(prefix))
+                                       return true;
+                               return false;
                        }
+               });
+               for(File f : files) {
+                       f = FileUtil.getCanonicalFile(f);
+                       if(logMINOR)
+                               Logger.minor(this, "Found " + f);
+                       originalFiles.add(f);
                }
+               
                bucketsToFree = new LinkedList();
        }



Reply via email to