X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FLocalReader.java;h=a28d4feadeeeb4502da949661923619acc16d241;hp=c17e83eaa097531eb423473d544c60eabff92a64;hb=bee7dffea9ef8d3312eee90993a9faaeac6c1127;hpb=b4dc6ab518ded2dd92e4cbb02ac615b1d57e8e6d diff --git a/src/be/nikiroo/fanfix/reader/LocalReader.java b/src/be/nikiroo/fanfix/reader/LocalReader.java index c17e83e..a28d4fe 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReader.java +++ b/src/be/nikiroo/fanfix/reader/LocalReader.java @@ -9,6 +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; class LocalReader extends BasicReader { private Library lib; @@ -46,12 +47,30 @@ class LocalReader extends BasicReader { public void read(int chapter) { } - // keep same luid - public void imprt(String luid) throws IOException { + /** + * Import the story into the local reader library, and keep the same LUID. + * + * @param luid + * the Library UID + * @param pg + * the optional progress reporter + * + * @throws IOException + * 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); + 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); } @@ -62,10 +81,23 @@ class LocalReader extends BasicReader { } } - public File getTarget(String luid) throws IOException { + /** + * Get the target file related to this {@link Story}. + * + * @param luid + * the LUID of the {@link Story} + * @param pg + * the optional progress reporter + * + * @return the target file + * + * @throws IOException + * in case of I/O error + */ + public File getTarget(String luid, Progress pg) throws IOException { File file = lib.getFile(luid); if (file == null) { - imprt(luid); + imprt(luid, pg); file = lib.getFile(luid); }