aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-09-03 14:39:45 -0700
committerScott Jackson <daneren2005@gmail.com>2014-09-03 14:39:45 -0700
commit469734452b0e7a6badb69681bb00974a4050774e (patch)
tree659f252aa167432b36b4c59285c60d7322977cec /src
parent2743a23154dd0491f97825a9f17cf50a134019a4 (diff)
downloaddsub-469734452b0e7a6badb69681bb00974a4050774e.tar.gz
dsub-469734452b0e7a6badb69681bb00974a4050774e.tar.bz2
dsub-469734452b0e7a6badb69681bb00974a4050774e.zip
Rework temp file logic to fix erroneous cache reset, add more indepth logging
createNewFile actually returns false if file already exists, not if the file failed to be created. If it fails, it should be throwing an exception. It already existing is not a good enough basis to fail and to cause the user issues. Also changed it to fail if it is not able to re-delete the file.
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/util/FileUtil.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java
index 7371b46b..b0657274 100644
--- a/src/github/daneren2005/dsub/util/FileUtil.java
+++ b/src/github/daneren2005/dsub/util/FileUtil.java
@@ -441,14 +441,20 @@ public class FileUtil {
public static boolean verifyCanWrite(File dir) {
if(ensureDirectoryExistsAndIsReadWritable(dir)) {
try {
- File tmp = new File(dir, "tmp");
- if(tmp.createNewFile()) {
- tmp.delete();
- return true;
+ File tmp = new File(dir, "checkWrite");
+ tmp.createNewFile();
+ if(tmp.exists()) {
+ if(tmp.delete()) {
+ return true;
+ } else {
+ Log.w(TAG, "Failed to delete temp file");
+ }
} else {
+ Log.w(TAG, "Temp file does not actually exist");
return false;
}
} catch(Exception e) {
+ Log.w(TAG, "Failed to create tmp file", e);
return false;
}
} else {