diff options
-rw-r--r-- | src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java | 2 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/FileUtil.java | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index 186f19c2..a55abfc0 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -443,7 +443,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { } else {
String path = prefs.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, null);
File cacheLocation = new File(path);
- if(!FileUtil.ensureDirectoryExistsAndIsReadWritable(cacheLocation)) {
+ if(!FileUtil.verifyCanWrite(cacheLocation)) {
resetCacheLocation(prefs);
Util.info(this, R.string.common_warning, R.string.settings_cache_location_reset);
}
diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java index 95917429..197a0149 100644 --- a/src/github/daneren2005/dsub/util/FileUtil.java +++ b/src/github/daneren2005/dsub/util/FileUtil.java @@ -368,6 +368,19 @@ public class FileUtil { } return true; } + public static boolean verifyCanWrite(File dir) { + if(ensureDirectoryExistsAndIsReadWritable(dir) { + try { + File tmp = File.createTempFile("tmp", "tmp", dir); + tmp.delete(); + return true; + } catch(Exception e) { + return false; + } + } else { + return false; + } + } /** * Makes a given filename safe by replacing special characters like slashes ("/" and "\") |