Code refactoring
[meviz.git] / src / main / java / eu / svjatoslav / meviz / htmlindexer / metadata / DirectoryMetadata.java
index f165694..0725382 100755 (executable)
@@ -1,11 +1,8 @@
 /*
- * Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012 -- 2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 3 of the GNU Lesser General Public License
- * or later as published by the Free Software Foundation.
-*/
+ * Meviz - Various tools collection to work with multimedia. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
+ */
+
 
 package eu.svjatoslav.meviz.htmlindexer.metadata;
 
@@ -36,15 +33,7 @@ public class DirectoryMetadata implements Serializable {
      * images that no longer exist in the filesystem.
      */
     public void cleanup() {
-        final Iterator<AbstractFile> fileIterator = fileNameToFileMap.values()
-                .iterator();
-
-        while (fileIterator.hasNext()) {
-            final AbstractFile file = fileIterator.next();
-
-            if (!file.isMetadataVerified())
-                fileIterator.remove();
-        }
+        fileNameToFileMap.values().removeIf(file -> !file.isMetadataVerified());
     }
 
     public void ensureFileMetadataIsUpToDate(final File parentDirectory,
@@ -76,6 +65,8 @@ public class DirectoryMetadata implements Serializable {
             try {
                 return new Picture(parentDirectory, fileName);
             } catch (final Exception exception) {
+                System.out.println("Failed to decode image \"" + fileName +"\" indexing as normal file instead.");
+
                 // in case image decoding failed, handle image as general file
                 return new GeneralFile(parentDirectory, fileName);
             }
@@ -106,7 +97,7 @@ public class DirectoryMetadata implements Serializable {
         final ArrayList<AbstractFile> files = new ArrayList<>(
                 fileNameToFileMap.values());
 
-        Collections.sort(files, new FileSortComparator());
+        files.sort(new FileSortComparator());
 
         return files;
     }