bugfix
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sat, 2 Nov 2013 23:00:31 +0000 (01:00 +0200)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sat, 2 Nov 2013 23:00:31 +0000 (01:00 +0200)
src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java
src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java

index d9726dd..58244f0 100755 (executable)
@@ -42,8 +42,6 @@ public class FilesystemIndexer extends AbstractIndexer {
 
        private final File directoryToIndex;
 
-       private String thumbnailsPath;
-
        private File metadataFile;
 
        private DirectoryMetadata metadata;
@@ -96,14 +94,6 @@ public class FilesystemIndexer extends AbstractIndexer {
                return Utils.isMevizGeneratedIndexFile(indexFile);
        }
 
-       public void cleanupUnusedMetadataFiles() {
-               final File thumbnailsDirectory = new File(thumbnailsPath);
-
-               for (final File file : thumbnailsDirectory.listFiles())
-                       if (!validMetadataFiles.contains(file.getName()))
-                               file.delete();
-       }
-
        public void generateHtmlFromMetadata(final HashSet<Layout> layouts) {
                // Generate HTML from metadata
                for (final Layout layout : layouts)
@@ -156,7 +146,9 @@ public class FilesystemIndexer extends AbstractIndexer {
                                .getRelativeThumbnailFileName(desiredDimension);
 
                validMetadataFiles.add(thumbnailFileName);
-               final File thumbnailFile = new File(thumbnailsPath + thumbnailFileName);
+               final File thumbnailFile = new File(
+                               Utils.getThumbnailsDirectoryPath(directoryToIndex)
+                                               + thumbnailFileName);
 
                if (!thumbnailFile.exists()) {
 
@@ -209,16 +201,18 @@ public class FilesystemIndexer extends AbstractIndexer {
        }
 
        public void loadOrCreateMetadata() {
-               metadataFile = new File(thumbnailsPath + Constants.METADATA_FILE_NAME);
+
+               metadataFile = new File(
+                               Utils.getThumbnailsDirectoryPath(directoryToIndex)
+                                               + Constants.METADATA_FILE_NAME);
 
                metadata = MetadadaHelper.initDirectoryMetadata(metadataFile);
        }
 
        private void removeUnusedThumbnailFiles() {
 
-               final File thumbnailsDirectory = new File(thumbnailsPath);
-
-               for (final File file : thumbnailsDirectory.listFiles())
+               for (final File file : Utils.getThumbnailsDirectory(directoryToIndex)
+                               .listFiles())
                        if (!validMetadataFiles.contains(file.getName()))
                                file.delete();
 
index f8c82fa..ab711a5 100755 (executable)
@@ -87,8 +87,12 @@ public class Utils {
        }
 
        public static File getThumbnailsDirectory(final File directoryToIndex) {
-               return new File(directoryToIndex.getAbsolutePath() + "/"
-                               + Constants.THUMBNAILS_DIRECTORY_NAME + "/");
+               return new File(getThumbnailsDirectoryPath(directoryToIndex));
+       }
+
+       public static String getThumbnailsDirectoryPath(final File directoryToIndex) {
+               return directoryToIndex.getAbsolutePath() + "/"
+                               + Constants.THUMBNAILS_DIRECTORY_NAME + "/";
        }
 
        public static boolean isMevizGeneratedIndexFile(final File indexFile)