Fix name of imported cbz, fix library check
authorNiki Roo <niki@nikiroo.be>
Sun, 26 Nov 2017 20:39:34 +0000 (21:39 +0100)
committerNiki Roo <niki@nikiroo.be>
Sun, 26 Nov 2017 20:39:34 +0000 (21:39 +0100)
changelog.md
src/be/nikiroo/fanfix/Instance.java
src/be/nikiroo/fanfix/reader/GuiReader.java
src/be/nikiroo/fanfix/supported/Epub.java

index 84493385f09728cef6ffaa25c9f718319efdd17b..d36c87f65d49bfae9c96b4e5c62d8c1f827fd025 100644 (file)
@@ -4,6 +4,7 @@
 
 - Bug fixes
 - Remote server/client improvements
+- Better support for some CBZ files (if SUMMARY or URL files are present in it)
 
 ## Version 1.6.2
 
index c48b119052ff24f5c184ccf89c79edf8dd78961c..97e9868b8858ad2475b96cb7f51df3ae50d04683 100644 (file)
@@ -82,12 +82,6 @@ public class Instance {
 
                uiconfig = new UiConfigBundle();
                trans = new StringIdBundle(getLang());
-               try {
-                       lib = new LocalLibrary(getFile(Config.LIBRARY_DIR));
-               } catch (Exception e) {
-                       syserr(new IOException("Cannot create library for directory: "
-                                       + getFile(Config.LIBRARY_DIR), e));
-               }
 
                boolean debug = Instance.getConfig()
                                .getBoolean(Config.DEBUG_ERR, false);
@@ -110,6 +104,13 @@ public class Instance {
                tracer.setShowErrorDetails(debug);
                tracer.setShowTraces(trace);
 
+               try {
+                       lib = new LocalLibrary(getFile(Config.LIBRARY_DIR));
+               } catch (Exception e) {
+                       syserr(new IOException("Cannot create library for directory: "
+                                       + getFile(Config.LIBRARY_DIR), e));
+               }
+
                // Could have used: System.getProperty("java.io.tmpdir")
                if (tmp == null) {
                        tmp = new File(configDir, "tmp");
@@ -200,6 +201,10 @@ public class Instance {
         * @return the {@link LocalLibrary}
         */
        public static BasicLibrary getLibrary() {
+               if (lib == null) {
+                       throw new NullPointerException("We don't have a library to return");
+               }
+
                return lib;
        }
 
index 8ff9d92072e76f6a29da2a7599decb0736e4c75b..9353794bf2d970884bf5ac2caec62d023bf285d6 100644 (file)
@@ -18,7 +18,6 @@ import be.nikiroo.fanfix.data.MetaData;
 import be.nikiroo.fanfix.data.Story;
 import be.nikiroo.fanfix.library.BasicLibrary;
 import be.nikiroo.fanfix.library.CacheLibrary;
-import be.nikiroo.fanfix.library.LocalLibrary;
 import be.nikiroo.utils.Progress;
 import be.nikiroo.utils.Version;
 import be.nikiroo.utils.ui.UIUtils;
index 6819ec29e272f1ee319fdf69da893b8d20855a77..b8c4af073805e5be8866213d4036936696bb334d 100644 (file)
@@ -6,6 +6,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map.Entry;
@@ -180,6 +181,14 @@ class Epub extends InfoText {
                        }
                        tmpInfo.delete();
                } else {
+                       if (title == null || title.isEmpty()) {
+                               title = new File(source.getPath()).getName();
+                               if (title.toLowerCase().endsWith(".cbz")) {
+                                       title = title.substring(0, title.length() - 4);
+                               }
+                               title = URLDecoder.decode(title, "UTF-8").trim();
+                       }
+
                        meta = new MetaData();
                        meta.setLang("EN");
                        meta.setTags(new ArrayList<String>());