From b6b657954954280c9ab0efcec67f3fe4a3ae0945 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Thu, 19 Sep 2019 13:15:30 +0200 Subject: [PATCH] remote/general: import should not retrieve story from server --- src/be/nikiroo/fanfix/Main.java | 7 ++++--- .../nikiroo/fanfix/library/BasicLibrary.java | 6 +++--- .../nikiroo/fanfix/library/CacheLibrary.java | 12 ++++++------ .../nikiroo/fanfix/library/RemoteLibrary.java | 18 +++++------------- .../fanfix/library/RemoteLibraryServer.java | 4 ++-- .../fanfix/reader/ui/GuiReaderFrame.java | 7 +++---- .../fanfix/reader/ui/GuiReaderMainPanel.java | 18 +++++++++--------- 7 files changed, 32 insertions(+), 40 deletions(-) diff --git a/src/be/nikiroo/fanfix/Main.java b/src/be/nikiroo/fanfix/Main.java index b3633612..3d69cad3 100644 --- a/src/be/nikiroo/fanfix/Main.java +++ b/src/be/nikiroo/fanfix/Main.java @@ -12,6 +12,7 @@ import javax.net.ssl.SSLException; import be.nikiroo.fanfix.bundles.Config; import be.nikiroo.fanfix.bundles.StringId; import be.nikiroo.fanfix.data.Chapter; +import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.library.BasicLibrary; import be.nikiroo.fanfix.library.CacheLibrary; @@ -644,10 +645,10 @@ public class Main { */ public static int imprt(String urlString, Progress pg) { try { - Story story = Instance.getLibrary().imprt( + MetaData meta = Instance.getLibrary().imprt( BasicReader.getUrl(urlString), pg); - System.out.println(story.getMeta().getLuid() + ": \"" - + story.getMeta().getTitle() + "\" imported."); + System.out.println(meta.getLuid() + ": \"" + meta.getTitle() + + "\" imported."); } catch (IOException e) { Instance.getTraceHandler().error(e); return 1; diff --git a/src/be/nikiroo/fanfix/library/BasicLibrary.java b/src/be/nikiroo/fanfix/library/BasicLibrary.java index 380c5c98..099859dc 100644 --- a/src/be/nikiroo/fanfix/library/BasicLibrary.java +++ b/src/be/nikiroo/fanfix/library/BasicLibrary.java @@ -751,14 +751,14 @@ abstract public class BasicLibrary { * @param pg * the optional progress reporter * - * @return the imported {@link Story} + * @return the imported Story {@link MetaData} * * @throws UnknownHostException * if the host is not supported * @throws IOException * in case of I/O error */ - public Story imprt(URL url, Progress pg) throws IOException { + public MetaData imprt(URL url, Progress pg) throws IOException { if (pg == null) pg = new Progress(); @@ -776,7 +776,7 @@ abstract public class BasicLibrary { Story story = save(support.process(pgProcess), pgSave); pg.done(); - return story; + return story.getMeta(); } /** diff --git a/src/be/nikiroo/fanfix/library/CacheLibrary.java b/src/be/nikiroo/fanfix/library/CacheLibrary.java index 019acd21..e128da52 100644 --- a/src/be/nikiroo/fanfix/library/CacheLibrary.java +++ b/src/be/nikiroo/fanfix/library/CacheLibrary.java @@ -345,7 +345,7 @@ public class CacheLibrary extends BasicLibrary { } @Override - public Story imprt(URL url, Progress pg) throws IOException { + public MetaData imprt(URL url, Progress pg) throws IOException { if (pg == null) { pg = new Progress(); } @@ -356,13 +356,13 @@ public class CacheLibrary extends BasicLibrary { pg.addProgress(pgImprt, 7); pg.addProgress(pgCache, 3); - Story story = lib.imprt(url, pgImprt); - cacheLib.save(story, story.getMeta().getLuid(), pgCache); - - updateInfo(story.getMeta()); + MetaData meta = lib.imprt(url, pgImprt); + updateInfo(meta); + + clearFromCache(meta.getLuid()); pg.done(); - return story; + return meta; } // All the following methods are only used by Save and Delete in diff --git a/src/be/nikiroo/fanfix/library/RemoteLibrary.java b/src/be/nikiroo/fanfix/library/RemoteLibrary.java index a6c68546..ce4305aa 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibrary.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibrary.java @@ -78,7 +78,7 @@ public class RemoteLibrary extends BasicLibrary { *
  • wl: flag to allow access to all the stories (bypassing the * whitelist if it exists)
  • * - * + *

    * Some examples: *