diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-03-03 10:24:41 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-03-03 10:24:41 -0800 |
commit | f8be58791ef6089707c5fb29dd0eefdc5e1b25e3 (patch) | |
tree | 58d5894ee2a1db4799b5fb56b42b6a9e731465d8 /src/github | |
parent | 68469f65ae5bcec21d8942f75a233fd998508c7f (diff) | |
download | dsub-f8be58791ef6089707c5fb29dd0eefdc5e1b25e3.tar.gz dsub-f8be58791ef6089707c5fb29dd0eefdc5e1b25e3.tar.bz2 dsub-f8be58791ef6089707c5fb29dd0eefdc5e1b25e3.zip |
Fix samsung returning File.canWrite true when false
Diffstat (limited to 'src/github')
-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 "\") |