From: Niki Roo Date: Sun, 26 Nov 2017 15:28:00 +0000 (+0100) Subject: Version 2.2.2 (manually delete from cache) X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=2ee6c205bfacff9e9a3103e7738afcd5e3267d3f;p=fanfix-jexer.git Version 2.2.2 (manually delete from cache) --- diff --git a/VERSION b/VERSION index c043eea..b1b25a5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.1 +2.2.2 diff --git a/changelog.md b/changelog.md index 131fae1..fb17b43 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # nikiroo-utils +## Version 2.2.2 + +- New method in Cache: manually delete items + ## Version 2.2.1 - Small fixes, especially in Progress diff --git a/src/be/nikiroo/utils/Cache.java b/src/be/nikiroo/utils/Cache.java index 60cd74e..1e59054 100644 --- a/src/be/nikiroo/utils/Cache.java +++ b/src/be/nikiroo/utils/Cache.java @@ -152,9 +152,6 @@ public class Cache { * used to check if the file is too old to keep or not * * @return the opened resource if found, NULL if not - * - * @throws IOException - * in case of I/O error */ public InputStream load(String uniqueID, boolean allowTooOld, boolean stable) { return load(getCached(uniqueID), allowTooOld, stable); @@ -172,19 +169,15 @@ public class Cache { * used to check if the file is too old to keep or not * * @return the opened resource if found, NULL if not - * - * @throws IOException - * in case of I/O error */ - public InputStream load(URL url, boolean allowTooOld, boolean stable) - throws IOException { + public InputStream load(URL url, boolean allowTooOld, boolean stable) { return load(getCached(url), allowTooOld, stable); } /** * Open a resource from the cache if it exists. * - * @param url + * @param cached * the resource to open * @param allowTooOld * allow files even if they are considered too old @@ -193,9 +186,6 @@ public class Cache { * used to check if the file is too old to keep or not * * @return the opened resource if found, NULL if not - * - * @throws IOException - * in case of I/O error */ private InputStream load(File cached, boolean allowTooOld, boolean stable) { if (cached.exists() && (allowTooOld || !isOld(cached, stable))) { @@ -236,6 +226,8 @@ public class Cache { * @param url * the {@link URL} used to locate the cached resource * + * @return the actual cache file + * * @throws IOException * in case of I/O error */ @@ -252,6 +244,8 @@ public class Cache { * @param cached * the cached {@link File} to save to * + * @return the actual cache file + * * @throws IOException * in case of I/O error */ @@ -260,6 +254,32 @@ public class Cache { return cached; } + /** + * Remove the given resource from the cache. + * + * @param uniqueID + * a unique ID used to locate the cached resource + * + * @return TRUE if it was removed + */ + public boolean remove(String uniqueID) { + File cached = getCached(uniqueID); + return cached.delete(); + } + + /** + * Remove the given resource from the cache. + * + * @param url + * the {@link URL} used to locate the cached resource + * + * @return TRUE if it was removed + */ + public boolean remove(URL url) { + File cached = getCached(url); + return cached.delete(); + } + /** * Check if the {@link File} is too old according to * {@link Cache#tooOldChanging}.