Sfoglia il codice sorgente

Throw exceptions is we fail to delete config file based things.

Change-Id: I4fa54ebe8f4ff93c8fc33504af66338eda01d0b8
Depends-On: I752f5bebe42514f1dc21e1b77e1ee5a649f324f5
Depends-On: I9463e66dc39881bcc69b64b8900df1010683b0bc
Depends-On: I752f5bebe42514f1dc21e1b77e1ee5a649f324f5
Reviewed-on: http://gerrit.dmdirc.com/3503
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
pull/1/head
Greg Holmes 10 anni fa
parent
commit
6c730e6ff2

+ 4
- 1
src/com/dmdirc/actions/wrappers/Profile.java Vedi File

@@ -27,6 +27,7 @@ import com.dmdirc.interfaces.config.IdentityFactory;
27 27
 
28 28
 import com.google.common.base.Preconditions;
29 29
 
30
+import java.io.IOException;
30 31
 import java.util.ArrayList;
31 32
 import java.util.Arrays;
32 33
 import java.util.List;
@@ -189,8 +190,10 @@ public class Profile {
189 190
 
190 191
     /**
191 192
      * Deletes the profile.
193
+     *
194
+     * @throws IOException if unable to delete the profile
192 195
      */
193
-    public void delete() {
196
+    public void delete() throws IOException {
194 197
         if (configProvider == null) {
195 198
             return;
196 199
         }

+ 1
- 1
src/com/dmdirc/config/ConfigFileBackedConfigProvider.java Vedi File

@@ -479,7 +479,7 @@ public class ConfigFileBackedConfigProvider extends BaseConfigProvider implement
479 479
     }
480 480
 
481 481
     @Override
482
-    public synchronized void delete() {
482
+    public synchronized void delete() throws IOException {
483 483
         if (file != null) {
484 484
             file.delete();
485 485
         }

+ 3
- 1
src/com/dmdirc/interfaces/config/ConfigProvider.java Vedi File

@@ -43,8 +43,10 @@ public interface ConfigProvider extends ReadOnlyConfigProvider {
43 43
 
44 44
     /**
45 45
      * Deletes this identity from disk.
46
+     *
47
+     * @throws IOException if the file fails to delete
46 48
      */
47
-    void delete();
49
+    void delete() throws IOException;
48 50
 
49 51
     /**
50 52
      * Returns the set of domains available in this identity.

+ 3
- 3
test/com/dmdirc/actions/wrappers/ProfileTest.java Vedi File

@@ -21,10 +21,10 @@
21 21
  */
22 22
 package com.dmdirc.actions.wrappers;
23 23
 
24
-import com.dmdirc.actions.wrappers.Profile;
25 24
 import com.dmdirc.interfaces.config.ConfigProvider;
26 25
 import com.dmdirc.interfaces.config.IdentityFactory;
27 26
 
27
+import java.io.IOException;
28 28
 import java.util.ArrayList;
29 29
 import java.util.Arrays;
30 30
 import java.util.List;
@@ -224,7 +224,7 @@ public class ProfileTest {
224 224
      * Test of delete method, of class Profile.
225 225
      */
226 226
     @Test
227
-    public void testDelete() {
227
+    public void testDelete() throws IOException {
228 228
         final List<String> nicknames = new ArrayList<>();
229 229
         nicknames.add("nickname1");
230 230
         nicknames.add("nickname2");
@@ -244,7 +244,7 @@ public class ProfileTest {
244 244
      * Test of delete method, of class Profile.
245 245
      */
246 246
     @Test
247
-    public void testDeleteNullIdentity() {
247
+    public void testDeleteNullIdentity() throws IOException {
248 248
         Profile instance = new Profile("New Profile", null);
249 249
         instance.delete();
250 250
     }

Loading…
Annulla
Salva