try +1
[fanfix.git] / src / be / nikiroo / fanfix / library / LocalLibrary.java
index 275926cd93164788258381b094fcef594cde7bbf..3d8aad12f904c7bc9123eccfb710507498a5f834 100644 (file)
@@ -86,7 +86,7 @@ public class LocalLibrary extends BasicLibrary {
 
                this.lastId = 0;
                this.stories = null;
-               this.sourceCovers = new HashMap<String, Image>();
+               this.sourceCovers = null;
 
                baseDir.mkdirs();
        }
@@ -127,9 +127,14 @@ public class LocalLibrary extends BasicLibrary {
        }
 
        @Override
-       protected synchronized void invalidateInfo(String luid) {
+       protected synchronized void updateInfo(MetaData meta) {
+               deleteInfo();
+       }
+
+       @Override
+       protected void deleteInfo(String luid) {
                stories = null;
-               sourceCovers = new HashMap<String, Image>();
+               sourceCovers = null;
        }
 
        @Override
@@ -189,11 +194,15 @@ public class LocalLibrary extends BasicLibrary {
                        }
                }
 
-               invalidateInfo();
+               deleteInfo();
        }
 
        @Override
        public Image getSourceCover(String source) {
+               if (sourceCovers == null) {
+                       getStories(null);
+               }
+
                if (!sourceCovers.containsKey(source)) {
                        sourceCovers.put(source, super.getSourceCover(source));
                }
@@ -203,6 +212,10 @@ public class LocalLibrary extends BasicLibrary {
 
        @Override
        public void setSourceCover(String source, String luid) {
+               if (sourceCovers == null) {
+                       getStories(null);
+               }
+
                sourceCovers.put(source, getCover(luid));
                File cover = new File(getExpectedDir(source), ".cover");
                try {
@@ -261,15 +274,13 @@ public class LocalLibrary extends BasicLibrary {
                                        pg.add(1);
                                }
 
-                               invalidateInfo();
+                               deleteInfo();
                                pg.done();
                                return;
                        }
                }
 
                super.imprt(other, luid, pg);
-
-               invalidateInfo();
        }
 
        /**
@@ -404,7 +415,7 @@ public class LocalLibrary extends BasicLibrary {
         * {@link LocalLibrary#baseDir}.
         * <p>
         * Will use a cached list when possible (see
-        * {@link BasicLibrary#invalidateInfo()}).
+        * {@link BasicLibrary#deleteInfo()}).
         * 
         * @param pg
         *            the optional {@link Progress}
@@ -420,6 +431,7 @@ public class LocalLibrary extends BasicLibrary {
 
                if (stories == null) {
                        stories = new HashMap<MetaData, File[]>();
+                       sourceCovers = new HashMap<String, Image>();
 
                        lastId = 0;
 
@@ -515,6 +527,10 @@ public class LocalLibrary extends BasicLibrary {
         *            the cover image
         */
        void setSourceCover(String source, Image coverImage) {
+               if (sourceCovers == null) {
+                       getStories(null);
+               }
+
                sourceCovers.put(source, coverImage);
                File cover = new File(getExpectedDir(source), ".cover");
                try {