import be.nikiroo.fanfix.bundles.UiConfig;
import be.nikiroo.fanfix.data.Story;
import be.nikiroo.fanfix.output.BasicOutput.OutputType;
-import be.nikiroo.utils.ui.Progress;
+import be.nikiroo.utils.Progress;
class LocalReader extends BasicReader {
private Library lib;
* in case of I/O error
*/
public void imprt(String luid, Progress pg) throws IOException {
+ Progress pgGetStory = new Progress();
+ Progress pgSave = new Progress();
+ if (pg != null) {
+ pg.setMax(2);
+ pg.addProgress(pgGetStory, 1);
+ pg.addProgress(pgSave, 1);
+ }
+
try {
- Story story = Instance.getLibrary().getStory(luid, pg);
+ Story story = Instance.getLibrary().getStory(luid, pgGetStory);
if (story != null) {
- story = lib.save(story, luid);
+ story = lib.save(story, luid, pgSave);
} else {
throw new IOException("Cannot find story in Library: " + luid);
}
return file;
}
+ /**
+ * Check if the {@link Story} denoted by this Library UID is present in the
+ * {@link LocalReader} cache.
+ *
+ * @param luid
+ * the Library UID
+ *
+ * @return TRUE if it is
+ */
+ public boolean isCached(String luid) {
+ return lib.getInfo(luid) != null;
+ }
+
@Override
public void start(String type) {
final String typeFinal = type;
}
});
}
+
+ void refresh(String luid) {
+ lib.delete(luid);
+ }
+
+ void delete(String luid) {
+ lib.delete(luid);
+ Instance.getLibrary().delete(luid);
+ }
}