From: Niki Roo Date: Sat, 2 Dec 2017 16:53:47 +0000 (+0100) Subject: Fix remote saving X-Git-Tag: fanfix-swing-0.0.1~12^2~384 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=0fa0fe9552e57bf05d8dd295a9d96d2364730c4e;p=fanfix-swing.git Fix remote saving --- diff --git a/src/be/nikiroo/fanfix/library/CacheLibrary.java b/src/be/nikiroo/fanfix/library/CacheLibrary.java index 62ac9fa7..28f56821 100644 --- a/src/be/nikiroo/fanfix/library/CacheLibrary.java +++ b/src/be/nikiroo/fanfix/library/CacheLibrary.java @@ -143,7 +143,7 @@ public class CacheLibrary extends BasicLibrary { pg.addProgress(pgCacheLib, 1); story = lib.save(story, luid, pgLib); - story = cacheLib.save(story, luid, pgCacheLib); + story = cacheLib.save(story, story.getMeta().getLuid(), pgCacheLib); clearCache(); diff --git a/src/be/nikiroo/fanfix/library/RemoteLibrary.java b/src/be/nikiroo/fanfix/library/RemoteLibrary.java index 06370320..f3104135 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibrary.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibrary.java @@ -191,16 +191,23 @@ public class RemoteLibrary extends BasicLibrary { @Override public synchronized Story save(final Story story, final String luid, Progress pg) throws IOException { - final Progress pgF = pg; + final String[] luidSaved = new String[1]; + Progress pgSave = new Progress(); + Progress pgRefresh = new Progress(); + if (pg == null) { + pg = new Progress(); + } + + pg.setMinMax(0, 10); + pg.addProgress(pgSave, 9); + pg.addProgress(pgRefresh, 1); + + final Progress pgF = pgSave; new ConnectActionClientObject(host, port, true) { @Override public void action(Version serverVersion) throws Exception { Progress pg = pgF; - if (pg == null) { - pg = new Progress(); - } - if (story.getMeta().getWords() <= Integer.MAX_VALUE) { pg.setMinMax(0, (int) story.getMeta().getWords()); } @@ -213,7 +220,9 @@ public class RemoteLibrary extends BasicLibrary { pg.add(1); } - send(null); + send(null); // done sending the story + luidSaved[0] = (String) send(null); // get LUID + pg.done(); } @@ -225,7 +234,10 @@ public class RemoteLibrary extends BasicLibrary { // because the meta changed: clearCache(); - story.setMeta(getInfo(luid)); + refresh(pgRefresh); + story.setMeta(getInfo(luidSaved[0])); + + pg.done(); return story; } diff --git a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java index 245e6fd9..c93f0f35 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java @@ -32,7 +32,7 @@ import be.nikiroo.utils.serial.server.ServerObject; *
  • [md5] GET_STORY [luid]: will return the given story if it exists (or NULL * if not)
  • *
  • [md5] SAVE_STORY [luid]: save the story (that must be sent just after the - * command) with the given LUID
  • + * command) with the given LUID, then return the LUID *
  • [md5] DELETE_STORY [luid]: delete the story of LUID luid
  • *
  • [md5] GET_COVER [luid]: return the cover of the story
  • *
  • [md5] GET_SOURCE_COVER [source]: return the cover for this source
  • @@ -132,6 +132,7 @@ public class RemoteLibraryServer extends ServerObject { Story story = rebuildStory(list); Instance.getLibrary().save(story, (String) args[0], null); + return story.getMeta().getLuid(); } else if ("DELETE_STORY".equals(command)) { Instance.getLibrary().delete((String) args[0]); } else if ("GET_COVER".equals(command)) {