CacheUtil throws IOExceptions now if there were issues reading file
info (that is to be cached)
This commit is contained in:
parent
f464b871a2
commit
48e3f0d784
@ -185,6 +185,8 @@ class CacheUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the name of the file in a cache, based on name. If cacheName is NULL, it will use the file's name.
|
* Saves the name of the file in a cache, based on name. If cacheName is NULL, it will use the file's name.
|
||||||
|
*
|
||||||
|
* @return the newly create cache file, or an IOException if there were problems
|
||||||
*/
|
*/
|
||||||
public static synchronized
|
public static synchronized
|
||||||
File save(String cacheName, final String fileName) throws IOException {
|
File save(String cacheName, final String fileName) throws IOException {
|
||||||
@ -203,7 +205,11 @@ class CacheUtil {
|
|||||||
|
|
||||||
// is file sitting on drive
|
// is file sitting on drive
|
||||||
File iconTest = new File(fileName);
|
File iconTest = new File(fileName);
|
||||||
if (iconTest.isFile() && iconTest.canRead()) {
|
if (iconTest.isFile()) {
|
||||||
|
if (!iconTest.canRead()) {
|
||||||
|
throw new IOException("File exists but unable to read source file " + fileName);
|
||||||
|
}
|
||||||
|
|
||||||
// have to copy the resource to the cache
|
// have to copy the resource to the cache
|
||||||
FileUtil.copyFile(iconTest, newFile);
|
FileUtil.copyFile(iconTest, newFile);
|
||||||
|
|
||||||
@ -213,6 +219,10 @@ class CacheUtil {
|
|||||||
// suck it out of a URL/Resource (with debugging if necessary)
|
// suck it out of a URL/Resource (with debugging if necessary)
|
||||||
final URL systemResource = LocationResolver.getResource(fileName);
|
final URL systemResource = LocationResolver.getResource(fileName);
|
||||||
|
|
||||||
|
if (systemResource == null) {
|
||||||
|
throw new IOException("Unable to load URL resource " + fileName);
|
||||||
|
}
|
||||||
|
|
||||||
InputStream inStream = systemResource.openStream();
|
InputStream inStream = systemResource.openStream();
|
||||||
|
|
||||||
// saves the file into our temp location, uses HASH of cacheName
|
// saves the file into our temp location, uses HASH of cacheName
|
||||||
|
Loading…
Reference in New Issue
Block a user