X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FLocalReader.java;h=6a66c199df79c4b6e48a4d189ecb7670e70c5175;hb=10d558d2429c984327f9e5a16933fefe5cc37314;hp=88ffc5d42d534dbbfbf1fa7d89c8de310ec4d79a;hpb=92fb0719f84f5b6734b51e528332546d78e9ccec;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/reader/LocalReader.java b/src/be/nikiroo/fanfix/reader/LocalReader.java index 88ffc5d..6a66c19 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReader.java +++ b/src/be/nikiroo/fanfix/reader/LocalReader.java @@ -9,7 +9,7 @@ import be.nikiroo.fanfix.Library; 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; @@ -59,10 +59,18 @@ class LocalReader extends BasicReader { * 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); } @@ -96,6 +104,10 @@ class LocalReader extends BasicReader { return file; } + public boolean isCached(String luid) { + return lib.getInfo(luid) != null; + } + @Override public void start(String type) { final String typeFinal = type; @@ -106,4 +118,13 @@ class LocalReader extends BasicReader { } }); } + + void refresh(String luid) { + lib.delete(luid); + } + + void delete(String luid) { + lib.delete(luid); + Instance.getLibrary().delete(luid); + } }