X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FRemoteLibrary.java;h=f3104135f2977b689a222ea68242c8bc5be75d27;hb=0fa0fe9552e57bf05d8dd295a9d96d2364730c4e;hp=9453d674e1df4c18f8ffd959b7f5ab916bf971e9;hpb=416c54f8bf5f60e2f8d7981e24fdd613fb9246f1;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/library/RemoteLibrary.java b/src/be/nikiroo/fanfix/library/RemoteLibrary.java index 9453d67..f310413 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; } @@ -270,6 +282,27 @@ public class RemoteLibrary extends BasicLibrary { "Operation not supportorted on remote Libraries"); } + /** + * Stop the server. + */ + public void exit() { + try { + new ConnectActionClientObject(host, port, true) { + @Override + public void action(Version serverVersion) throws Exception { + send(new Object[] { md5, "EXIT" }); + } + + @Override + protected void onError(Exception e) { + Instance.getTraceHandler().error(e); + } + }.connect(); + } catch (IOException e) { + Instance.getTraceHandler().error(e); + } + } + @Override protected List getMetas(Progress pg) { final Progress pgF = pg;