X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FBasicLibrary.java;h=9e7d4644494e5b51d871091868c3c1e47d882f53;hb=e272f05fd49f01e9fb6bd71c7b74a32839bbcc38;hp=430fb2026a256510bb7705eea22ce799005ab48e;hpb=e6249b0f26fd3a7ec4cf5e49ba9f9939018c43d3;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/library/BasicLibrary.java b/src/be/nikiroo/fanfix/library/BasicLibrary.java index 430fb20..9e7d464 100644 --- a/src/be/nikiroo/fanfix/library/BasicLibrary.java +++ b/src/be/nikiroo/fanfix/library/BasicLibrary.java @@ -4,6 +4,7 @@ import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.net.URL; +import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -134,7 +135,19 @@ abstract public class BasicLibrary { * Invalidate the {@link Story} cache (when the content should be re-read * because it was changed). */ - protected abstract void clearCache(); + protected void invalidateInfo() { + invalidateInfo(null); + } + + /** + * Invalidate the {@link Story} cache (when the content should be re-read + * because it was changed). + * + * @param luid + * the luid of the {@link Story} to clear from the cache, or NULL + * for all stories + */ + protected abstract void invalidateInfo(String luid); /** * Return the next LUID that can be used. @@ -368,13 +381,15 @@ abstract public class BasicLibrary { * * @return the imported {@link Story} * + * @throws UnknownHostException + * if the host is not supported * @throws IOException * in case of I/O error */ public Story imprt(URL url, Progress pg) throws IOException { BasicSupport support = BasicSupport.getSupport(url); if (support == null) { - throw new IOException("URL not supported: " + url.toString()); + throw new UnknownHostException("" + url); } return save(support.process(url, pg), null); @@ -442,7 +457,7 @@ abstract public class BasicLibrary { pg.addProgress(pgOut, 1); } - BasicOutput out = BasicOutput.getOutput(type, false); + BasicOutput out = BasicOutput.getOutput(type, false, false); if (out == null) { throw new IOException("Output type not supported: " + type); } @@ -502,13 +517,13 @@ abstract public class BasicLibrary { meta.setLuid(luid); } - if (getInfo(luid) != null) { + if (luid != null && getInfo(luid) != null) { delete(luid); } doSave(story, pg); - clearCache(); + invalidateInfo(luid); return story; } @@ -524,7 +539,7 @@ abstract public class BasicLibrary { */ public synchronized void delete(String luid) throws IOException { doDelete(luid); - clearCache(); + invalidateInfo(luid); } /**