Fixes:
authorNiki Roo <niki@nikiroo.be>
Sat, 11 Aug 2018 13:28:57 +0000 (15:28 +0200)
committerNiki Roo <niki@nikiroo.be>
Sat, 11 Aug 2018 13:28:57 +0000 (15:28 +0200)
- item disappeared until restart when removing from cache (remote + gui)
- chapter numbers were not correct on MangaLel (inverted, but no real effect)
- more logging on client

src/be/nikiroo/fanfix/data/Paragraph.java
src/be/nikiroo/fanfix/library/BasicLibrary.java
src/be/nikiroo/fanfix/library/CacheLibrary.java
src/be/nikiroo/fanfix/library/LocalLibrary.java
src/be/nikiroo/fanfix/reader/BasicReader.java
src/be/nikiroo/fanfix/supported/Cbz.java
src/be/nikiroo/fanfix/supported/MangaLel.java

index 91e95f8bd791f545ce185c5c194c843ff0e4dbe8..e7ef04581fc3b2d70c05d19d1b203971ba2136b2 100644 (file)
@@ -137,7 +137,8 @@ public class Paragraph implements Cloneable {
         */
        @Override
        public String toString() {
-               return String.format("%s: [%s]", "" + type, "" + content);
+               return String.format("%s: [%s]", "" + type, content == null ? "N/A"
+                               : content);
        }
 
        @Override
index ee7ee8d48c225994343579efec3f2f381be9eabc..56a57070b0e2ab66fb0d78d97a43c847ed2cc06d 100644 (file)
@@ -519,6 +519,9 @@ abstract public class BasicLibrary {
        public synchronized Story save(Story story, String luid, Progress pg)
                        throws IOException {
 
+               Instance.getTraceHandler().trace(
+                               this.getClass().getSimpleName() + ": saving story " + luid);
+
                // Do not change the original metadata, but change the original story
                MetaData meta = story.getMeta().clone();
                story.setMeta(meta);
@@ -537,6 +540,10 @@ abstract public class BasicLibrary {
 
                updateInfo(story.getMeta());
 
+               Instance.getTraceHandler().trace(
+                               this.getClass().getSimpleName() + ": story saved (" + luid
+                                               + ")");
+
                return story;
        }
 
@@ -550,8 +557,15 @@ abstract public class BasicLibrary {
         *             in case of I/O error
         */
        public synchronized void delete(String luid) throws IOException {
+               Instance.getTraceHandler().trace(
+                               this.getClass().getSimpleName() + ": deleting story " + luid);
+
                doDelete(luid);
                deleteInfo(luid);
+
+               Instance.getTraceHandler().trace(
+                               this.getClass().getSimpleName() + ": story deleted (" + luid
+                                               + ")");
        }
 
        /**
index a9063308f8faf2ca0741c22b0e2cb21ea198ef96..977331f33ecf0783084f730414b0862dd1de86c1 100644 (file)
@@ -242,7 +242,6 @@ public class CacheLibrary extends BasicLibrary {
        public void clearFromCache(String luid) throws IOException {
                if (isCached(luid)) {
                        cacheLib.delete(luid);
-                       deleteInfo(luid);
                }
        }
 
index 3d8aad12f904c7bc9123eccfb710507498a5f834..bdded01810ebedc0452867175da9eb1b3899ffdb 100644 (file)
@@ -98,12 +98,25 @@ public class LocalLibrary extends BasicLibrary {
 
        @Override
        public File getFile(String luid, Progress pg) {
-               File[] files = getStories(pg).get(getInfo(luid));
+               Instance.getTraceHandler().trace(
+                               this.getClass().getSimpleName() + ": get file for " + luid);
+
+               File file = null;
+               String mess = "no file found for ";
+
+               MetaData meta = getInfo(luid);
+               Instance.getTraceHandler().trace("(info is: " + meta + ")");
+
+               File[] files = getStories(pg).get(meta);
                if (files != null) {
-                       return files[1];
+                       mess = "file retrieved for ";
+                       file = files[1];
                }
 
-               return null;
+               Instance.getTraceHandler().trace(
+                               this.getClass().getSimpleName() + ": " + mess + luid);
+
+               return file;
        }
 
        @Override
@@ -420,7 +433,8 @@ public class LocalLibrary extends BasicLibrary {
         * @param pg
         *            the optional {@link Progress}
         * 
-        * @return the list of stories
+        * @return the list of stories (for each item, the first {@link File} is the info file, the
+        *         second file is the target {@link File})
         */
        private synchronized Map<MetaData, File[]> getStories(Progress pg) {
                if (pg == null) {
index 9d5d5bb80b1b9206ec2d918293c7ff23da5ab1eb..8285edb47e74266bc747662fb3bbec87b5ae5460 100644 (file)
@@ -267,6 +267,8 @@ public abstract class BasicReader implements Reader {
                        for (String starter : new String[] { "xdg-open", "open", "see",
                                        "start", "run" }) {
                                try {
+                                       Instance.getTraceHandler().trace(
+                                                       "starting external program");
                                        Runtime.getRuntime().exec(
                                                        new String[] { starter, target.getAbsolutePath() });
                                        ok = true;
@@ -278,6 +280,7 @@ public abstract class BasicReader implements Reader {
                                throw new IOException("Cannot find a program to start the file");
                        }
                } else {
+                       Instance.getTraceHandler().trace("starting external program");
                        Runtime.getRuntime().exec(
                                        new String[] { program, target.getAbsolutePath() });
                }
index 1cf07c5d0f162c0f300e4a389c0a6282819e7c99..6fadad7c5ce558561d007b3c08a3934844d82f3e 100644 (file)
@@ -156,8 +156,6 @@ class Cbz extends Epub {
                                meta.setCover(images.get(imagesList.get(0)));
                                meta.setFakeCover(true);
                        }
-                       
-System.out.println("Meta from Cbz support at end: "+meta);
                } finally {
                        IOUtils.deltree(tmpDir);
                        if (zipIn != null) {
index 43d0b2cff22972d6e45dc245ae4b3669ae4bfd9a..0351622e8ef66b66d6563c6a0920e3f4f8a8edb2 100644 (file)
@@ -156,14 +156,16 @@ class MangaLel extends BasicSupport {
        protected List<Entry<String, URL>> getChapters(Progress pg) {
                List<Entry<String, URL>> urls = new ArrayList<Entry<String, URL>>();
 
-               int i = 1;
+               int i = 0;
                Element doc = getSourceNode();
-               Element chapEls = doc.getElementsByClass("chapters").first();
-               for (Element chapEl : chapEls.getElementsByTag("li")) {
+               Elements chapEls = doc.getElementsByClass("chapters").first()
+                               .getElementsByTag("li");
+               for (Element chapEl : chapEls) {
                        Element titleEl = chapEl.getElementsByTag("h5").first();
                        String title = StringUtils.unhtml(titleEl.text()).trim();
-                       title = Integer.toString(i++); // because Atril does not support
-                                                                                       // strange file names
+
+                       // because Atril does not support strange file names
+                       title = Integer.toString(chapEls.size() - i);
 
                        Element linkEl = chapEl.getElementsByTag("h5").first()
                                        .getElementsByTag("a").first();
@@ -175,6 +177,8 @@ class MangaLel extends BasicSupport {
                        } catch (MalformedURLException e) {
                                Instance.getTraceHandler().error(e);
                        }
+
+                       i++;
                }
 
                Collections.reverse(urls);