From: Niki Roo Date: Sat, 11 Aug 2018 13:28:57 +0000 (+0200) Subject: Fixes: X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=9e2fad3600cd08eca73d45cb5c991d98095842aa;p=fanfix-jexer.git Fixes: - 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 --- diff --git a/src/be/nikiroo/fanfix/data/Paragraph.java b/src/be/nikiroo/fanfix/data/Paragraph.java index 91e95f8..e7ef045 100644 --- a/src/be/nikiroo/fanfix/data/Paragraph.java +++ b/src/be/nikiroo/fanfix/data/Paragraph.java @@ -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 diff --git a/src/be/nikiroo/fanfix/library/BasicLibrary.java b/src/be/nikiroo/fanfix/library/BasicLibrary.java index ee7ee8d..56a5707 100644 --- a/src/be/nikiroo/fanfix/library/BasicLibrary.java +++ b/src/be/nikiroo/fanfix/library/BasicLibrary.java @@ -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 + + ")"); } /** diff --git a/src/be/nikiroo/fanfix/library/CacheLibrary.java b/src/be/nikiroo/fanfix/library/CacheLibrary.java index a906330..977331f 100644 --- a/src/be/nikiroo/fanfix/library/CacheLibrary.java +++ b/src/be/nikiroo/fanfix/library/CacheLibrary.java @@ -242,7 +242,6 @@ public class CacheLibrary extends BasicLibrary { public void clearFromCache(String luid) throws IOException { if (isCached(luid)) { cacheLib.delete(luid); - deleteInfo(luid); } } diff --git a/src/be/nikiroo/fanfix/library/LocalLibrary.java b/src/be/nikiroo/fanfix/library/LocalLibrary.java index 3d8aad1..bdded01 100644 --- a/src/be/nikiroo/fanfix/library/LocalLibrary.java +++ b/src/be/nikiroo/fanfix/library/LocalLibrary.java @@ -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 getStories(Progress pg) { if (pg == null) { diff --git a/src/be/nikiroo/fanfix/reader/BasicReader.java b/src/be/nikiroo/fanfix/reader/BasicReader.java index 9d5d5bb..8285edb 100644 --- a/src/be/nikiroo/fanfix/reader/BasicReader.java +++ b/src/be/nikiroo/fanfix/reader/BasicReader.java @@ -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() }); } diff --git a/src/be/nikiroo/fanfix/supported/Cbz.java b/src/be/nikiroo/fanfix/supported/Cbz.java index 1cf07c5..6fadad7 100644 --- a/src/be/nikiroo/fanfix/supported/Cbz.java +++ b/src/be/nikiroo/fanfix/supported/Cbz.java @@ -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) { diff --git a/src/be/nikiroo/fanfix/supported/MangaLel.java b/src/be/nikiroo/fanfix/supported/MangaLel.java index 43d0b2c..0351622 100644 --- a/src/be/nikiroo/fanfix/supported/MangaLel.java +++ b/src/be/nikiroo/fanfix/supported/MangaLel.java @@ -156,14 +156,16 @@ class MangaLel extends BasicSupport { protected List> getChapters(Progress pg) { List> urls = new ArrayList>(); - 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);