Browse Source

Handle errors when creating defaults dirs properly

If we can't create the defaults directory it's a Very Bad Sign™, and
we should bail out immediately. It probably means the user is running
from a directory they don't have write access to, and if we can't
write defaults then the client isn't going to work very well at all.

Previous behaviour tried to carry on and failed a precondition check
and died even more painfully.

Change-Id: Id72fb63c014939ac384ee03b9eb0f14baf6e18fe
Fixes-Issue: CLIENT-488
Reviewed-on: http://gerrit.dmdirc.com/3335
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
Reviewed-on: http://gerrit.dmdirc.com/3348
tags/0.8.1rc1
Chris Smith 10 years ago
parent
commit
9a9872e754
1 changed files with 7 additions and 2 deletions
  1. 7
    2
      src/com/dmdirc/config/IdentityManager.java

+ 7
- 2
src/com/dmdirc/config/IdentityManager.java View File

@@ -162,8 +162,13 @@ public class IdentityManager implements IdentityFactory, IdentityController {
162 162
                 }
163 163
             }
164 164
 
165
-            if (!file.exists() || file.listFiles() == null || file.listFiles().length == 0) {
166
-                file.mkdirs();
165
+            if (!file.exists() && !file.mkdirs()) {
166
+                Logger.userError(ErrorLevel.FATAL, "Unable to create required directory '"
167
+                        + file.getAbsolutePath() + "'. Please check file permissions or specify "
168
+                        + "a different configuration directory.");
169
+            }
170
+
171
+            if (file.listFiles() == null || file.listFiles().length == 0) {
167 172
                 extractIdentities(target);
168 173
             }
169 174
 

Loading…
Cancel
Save