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();
@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());
}
pg.add(1);
}
- send(null);
+ send(null); // done sending the story
+ luidSaved[0] = (String) send(null); // get LUID
+
pg.done();
}
// because the meta changed:
clearCache();
- story.setMeta(getInfo(luid));
+ refresh(pgRefresh);
+ story.setMeta(getInfo(luidSaved[0]));
+
+ pg.done();
return story;
}
* <li>[md5] GET_STORY [luid]: will return the given story if it exists (or NULL
* if not)</li>
* <li>[md5] SAVE_STORY [luid]: save the story (that must be sent just after the
- * command) with the given LUID</li>
+ * command) with the given LUID, then return the LUID</li>
* <li>[md5] DELETE_STORY [luid]: delete the story of LUID luid</li>
* <li>[md5] GET_COVER [luid]: return the cover of the story</li>
* <li>[md5] GET_SOURCE_COVER [source]: return the cover for this source</li>
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)) {