- private File save(InputStream in, File cached) throws IOException {
- IOUtils.write(in, cached);
- return cached;
+ private long save(InputStream in, File cached) throws IOException {
+ // We want to force at least an immediate SAVE/LOAD to work for some
+ // workflows, even if we don't accept cached files (times set to "0"
+ // -- and not "-1" or a positive value)
+ clean(true, dir, 10);
+ cached.getParentFile().mkdirs(); // in case we deleted our own parent
+ long bytes = IOUtils.write(in, cached);
+ return bytes;
+ }
+
+ /**
+ * 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();