Permalink
Browse files

fixed cache dir issues

  • Loading branch information...
1 parent e8f5642 commit 46b04e14045813bffa73f27a7220b58960725a33 @anti43 committed Aug 28, 2013
Showing with 11 additions and 5 deletions.
  1. +11 −5 src/mpv5/utils/files/FileDirectoryHandler.java
@@ -571,28 +571,34 @@ public static URI copyFile(File sourceFile, File outp, boolean silent) throws Fi
public static URI copyFile(File sourceFile, File outp) throws FileNotFoundException, IOException {
return copyFile(sourceFile, outp, true);
}
+
+ private static void cacheCheck(){
+ return cacheCheck(true);
+ }
- private static void cacheCheck() {
+ private static void cacheCheck(boolean tryagain) {
File e = null;
try {
e = new File(LocalSettings.getProperty(LocalSettings.CACHE_DIR));
} catch (Exception ex) {//avoid npe
Log.Debug(ex);
- LocalSettings.setProperty(LocalSettings.CACHE_DIR, System.getProperty("java.io.tmpdir") + Constants.FALLBACK_CACHE_DIR);
+ LocalSettings.setProperty(LocalSettings.CACHE_DIR, System.getProperty("java.io.tmpdir") + File.separator + Constants.FALLBACK_CACHE_DIR);
e = new File(System.getProperty("java.io.tmpdir"), Constants.FALLBACK_CACHE_DIR);
}
if (!e.exists()) {
e.mkdirs();
}
//Cannot access Cache dir?
- if (!e.isDirectory() || !e.canWrite() || e.listFiles() == null) {
- LocalSettings.setProperty(LocalSettings.CACHE_DIR, System.getProperty("java.io.tmpdir") + Constants.FALLBACK_CACHE_DIR);
- cacheCheck();
+ if (tryagain && (!e.isDirectory() || !e.canWrite() || e.listFiles() == null)) {
+ LocalSettings.setProperty(LocalSettings.CACHE_DIR, System.getProperty("java.io.tmpdir") + File.separator + Constants.FALLBACK_CACHE_DIR);
+ cacheCheck(false);
try {
FileDirectoryHandler.deleteTreeOnExit(getTempDirAsFile());
} catch (IOException ex) {
Log.Debug(ex);
}
+ }else{
+ throw new IllegalStateException("Cache dir not writeable: " + String.valueOf(e));
}
}

0 comments on commit 46b04e1

Please sign in to comment.