felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r937979 - /felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Scanner.java
Date Mon, 26 Apr 2010 09:27:04 GMT
Author: gnodet
Date: Mon Apr 26 09:26:58 2010
New Revision: 937979

URL: http://svn.apache.org/viewvc?rev=937979&view=rev
Log:
FELIX-2201: [FileInstall] Make Scanner process artifacts in 'oldest-file-modification-time
first' order

Modified:
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Scanner.java

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Scanner.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Scanner.java?rev=937979&r1=937978&r2=937979&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Scanner.java
(original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Scanner.java
Mon Apr 26 09:26:58 2010
@@ -20,11 +20,13 @@ package org.apache.felix.fileinstall.int
 
 import java.io.File;
 import java.io.FilenameFilter;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeSet;
 import java.util.zip.CRC32;
 
 /**
@@ -101,7 +103,7 @@ public class Scanner {
         {
             return null;
         }
-        Set/*<File>*/ files = new HashSet/*<File>*/();
+        Set/*<File>*/ files = new TreeSet/*<File>*/(new FileModificationTimeComparator());
         Set/*<File>*/ removed = new HashSet/*<File>*/(storedChecksums.keySet());
         for (int i = 0; i < list.length; i++)
         {
@@ -186,4 +188,18 @@ public class Scanner {
         }
     }
 
+    /**
+     * {@link Comparator} that sorts {@link File}s in increasing order of modification time
+     * ("oldest first").
+     */
+    private final static class FileModificationTimeComparator implements Comparator
+    {
+        public int compare(Object arg0, Object arg1)
+        {
+            File lhs = (File) arg0;
+            File rhs = (File) arg1;
+            return (int) (lhs.lastModified() - rhs.lastModified());
+        }
+    }
+
 }



Mime
View raw message