Эх сурвалжийг харах

Merge pull request #605 from nextcloud/bug_597

Don't restore from unknown state for migration. Fixes #597
Mario Đanić 8 жил өмнө
parent
commit
bb22b9d50b

+ 9 - 3
src/com/owncloud/android/ui/activity/StorageMigration.java

@@ -175,7 +175,7 @@ public class StorageMigration {
                                      String source,
                                      String target,
                                      ProgressDialog progressDialog,
-                                     StorageMigrationProgressListener listener) {
+                                     StorageMigrationProgressListener listener) throws SecurityException {
             mContext = context;
             mStorageSource = source;
             mStorageTarget = target;
@@ -242,6 +242,12 @@ public class StorageMigration {
         }
 
         protected void restoreAccountsSyncStatus(boolean oldSync[]) {
+            // If we don't have the old sync statuses, then
+            // probably migration failed even before saving states,
+            // which is weird and should be investigated.
+            // But its better than crashing on ArrayOutOfBounds.
+            if (oldSync == null)
+                return;
             for (int i = 0; i < mOcAccounts.length; ++i) {
                 ContentResolver.setSyncAutomatically(mOcAccounts[i], mAuthority, oldSync[i]);
             }
@@ -263,7 +269,7 @@ public class StorageMigration {
             publishProgress(R.string.file_migration_preparing);
 
             Log_OC.stopLogging();
-            boolean[] syncStates = new boolean[0];
+            boolean[] syncStates = null;
             try {
                 publishProgress(R.string.file_migration_saving_accounts_configuration);
                 syncStates = saveAccountsSyncStatus();
@@ -306,7 +312,7 @@ public class StorageMigration {
             publishProgress(R.string.file_migration_preparing);
             Log_OC.stopLogging();
 
-            boolean[] syncState = new boolean[0];
+            boolean[] syncState = null;
 
             try {
                 File dstFile = new File(mStorageTarget + File.separator + MainApp.getDataFolder());