+ public synchronized Story save(final Story story, final String luid,
+ Progress pg) throws IOException {
+ final Progress pgF = pg;
+
+ 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());
+ }
+
+ send(new Object[] { md5, "SAVE_STORY", luid });
+
+ List<Object> list = RemoteLibraryServer.breakStory(story);
+ for (Object obj : list) {
+ send(obj);
+ pg.add(1);
+ }
+
+ send(null);
+ pg.done();
+ }
+
+ @Override
+ protected void onError(Exception e) {
+ Instance.getTraceHandler().error(e);
+ }
+ }.connect();
+
+ // because the meta changed:
+ clearCache();
+ story.setMeta(getInfo(luid));
+
+ return story;