.../apache/jackrabbit/core/data/LocalCache.java | 45 +++++++++------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/LocalCache.java b/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/LocalCache.java index 21c33ee..914ae45 100644 --- a/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/LocalCache.java +++ b/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/LocalCache.java @@ -107,26 +107,7 @@ public class LocalCache { (cachePurgeResizeFactor * maxSizeInBytes) }); cache = new LRUCache(maxSizeInBytes, cachePurgeTrigFactor, cachePurgeResizeFactor); this.asyncUploadCache = asyncUploadCache; - long startTime = System.currentTimeMillis(); - ArrayList allFiles = new ArrayList(); - Iterator it = FileUtils.iterateFiles(directory, null, true); - while (it.hasNext()) { - File f = it.next(); - allFiles.add(f); - } - long t1 = System.currentTimeMillis(); - LOG.debug("Time taken to recursive [{}] took [{}] sec", - allFiles.size(), ((t1 - startTime) / 1000)); - Collections.sort(allFiles, new Comparator() { - public int compare(File o1, File o2) { - long l1 = o1.lastModified(), l2 = o2.lastModified(); - return l1 < l2 ? -1 : l1 > l2 ? 1 : 0; - } - }); - long t2 = System.currentTimeMillis(); - LOG.debug("Time taken to sort [{}] took [{}] sec", - allFiles.size(), ((t2 - t1) / 1000)); - new Thread(new CacheBuildJob(allFiles)).start(); + new Thread(new CacheBuildJob()).start(); } /** @@ -596,17 +577,26 @@ public class LocalCache { */ private class CacheBuildJob implements Runnable { - List allFiles ; - private CacheBuildJob(List allFiles) { - this.allFiles = allFiles; - } public void run() { long startTime = System.currentTimeMillis(); + ArrayList allFiles = new ArrayList(); + Iterator it = FileUtils.iterateFiles(directory, null, true); + while (it.hasNext()) { + File f = it.next(); + allFiles.add(f); + } + long t1 = System.currentTimeMillis(); + LOG.debug("Time taken to recursive [{}] took [{}] sec", + allFiles.size(), ((t1 - startTime) / 1000)); + String dataStorePath = directory.getAbsolutePath(); - LOG.info("directoryPath = " + dataStorePath); + // convert to java path format dataStorePath = dataStorePath.replace("\\", "/"); + LOG.info("directoryPath = " + dataStorePath); + String tmpPath = tmp.getAbsolutePath(); + tmpPath = tmpPath.replace("\\", "/"); LOG.debug("tmp path [{}]", tmpPath); long time = System.currentTimeMillis(); int count = 0; @@ -615,6 +605,9 @@ public class LocalCache { count++; String name = f.getPath(); String filePath = f.getAbsolutePath(); + // convert to java path format + name = name.replace("\\", "/"); + filePath = filePath.replace("\\", "/"); // skipped any temp file if(filePath.startsWith(tmpPath) ) { LOG.info ("tmp file [{}] skipped ", filePath); @@ -623,8 +616,6 @@ public class LocalCache { if (name.startsWith(dataStorePath)) { name = name.substring(dataStorePath.length()); } - // convert to java path format - name = name.replace("\\", "/"); if (name.startsWith("/") || name.startsWith("\\")) { name = name.substring(1); }