diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-03-03 17:55:05 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-03-03 17:55:05 -0800 |
commit | c9795f949df7ad3becc89f41b73a616d7c0ee483 (patch) | |
tree | 1ce22bae253a9dc51de6a8438a06f07beab1fa5d /src | |
parent | 4699dfddcbe616af65de672fcbbfc407cc65ceff (diff) | |
parent | d1da3fcf362584224aba0dbf6ba77cc47f079b14 (diff) | |
download | dsub-c9795f949df7ad3becc89f41b73a616d7c0ee483.tar.gz dsub-c9795f949df7ad3becc89f41b73a616d7c0ee483.tar.bz2 dsub-c9795f949df7ad3becc89f41b73a616d7c0ee483.zip |
Merge branch 'samsung' of https://github.com/daneren2005/Subsonic
Diffstat (limited to 'src')
-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 ce08d422..5aee380f 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..a1983fde 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 "\") |