diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-09-03 14:39:45 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-09-03 14:39:45 -0700 |
commit | 469734452b0e7a6badb69681bb00974a4050774e (patch) | |
tree | 659f252aa167432b36b4c59285c60d7322977cec /src/github | |
parent | 2743a23154dd0491f97825a9f17cf50a134019a4 (diff) | |
download | dsub-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/github')
-rw-r--r-- | src/github/daneren2005/dsub/util/FileUtil.java | 14 |
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 { |