Skip to content
This repository
Browse code

fixes Restore Error on very first install

  • Loading branch information...
commit 06de54334305a6eb681300b935e576af2d64f4a8 1 parent 45615fb
Sean McArthur authored November 29, 2011
9  src/com/monstarlab/servicedroid/model/BackupWorker.java
@@ -15,6 +15,7 @@
15 15
 import android.net.Uri;
16 16
 import android.provider.BaseColumns;
17 17
 import android.text.TextUtils;
  18
+import android.util.Log;
18 19
 
19 20
 
20 21
 /**
@@ -26,6 +27,8 @@
26 27
  */
27 28
 public class BackupWorker {
28 29
 	
  30
+	private static final String TAG = "BackupWorker";
  31
+	
29 32
 	private static final String TIME_ENTRY_TAG = "TimeEntry";
30 33
 	private static final String CALL_TAG = "Call";
31 34
 	private static final String RETURN_VISIT_TAG = "ReturnVisit";
@@ -79,13 +82,15 @@ protected void pushDataOntoDocument(ServiceDroidDocument doc, String tag, Conten
79 82
 	}
80 83
 	
81 84
 	public boolean restore(ContentResolver resolver, String xml) {
82  
-		//receive XML, so decode it
83 85
 		if (TextUtils.isEmpty(xml)) {
84  
-			return false;
  86
+			// There is no file at first install, so this is a "success".
  87
+			Log.i(TAG, "Backup file was empty (if existed).");
  88
+			return true;
85 89
 		}
86 90
 		
87 91
 		ServiceDroidDocument doc = new ServiceDroidDocument(xml);
88 92
 		if (!doc.isValid()) {
  93
+			Log.e(TAG, "Backup file is invalid XML.");
89 94
 			return false;
90 95
 		}
91 96
 		
2  src/com/monstarlab/servicedroid/service/BackupService.java
@@ -217,7 +217,7 @@ protected String readFromSDCard() {
217 217
 			// Restore failing, but there *might* be a restore file there,
218 218
 			// should we try again a little later? much later and we risk data
219 219
 			// contamination
220  
-			Log.w(TAG, "error writing to file");
  220
+			Log.e(TAG, "error reading ServiceDroidBackup.sdml");
221 221
 		}
222 222
 		return sb.toString();
223 223
 	}

0 notes on commit 06de543

Please sign in to comment.
Something went wrong with that request. Please try again.