浏览代码

ConflictsResolveActivity: remove upload is KEEP_SERVER and shouldDeleteLocal

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
Álvaro Brey Vilas 3 年之前
父节点
当前提交
c5b75f68b0
共有 1 个文件被更改,包括 17 次插入6 次删除
  1. 17 6
      src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.java

+ 17 - 6
src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.java

@@ -142,12 +142,16 @@ public class ConflictsResolveActivity extends FileActivity implements OnConflict
                     uploadsStorageManager.removeUpload(upload);
                     break;
                 case KEEP_SERVER: // Download
-                    // Overwrite local file
-                    Intent intent = new Intent(getBaseContext(), FileDownloader.class);
-                    intent.putExtra(FileDownloader.EXTRA_USER, getUser().orElseThrow(RuntimeException::new));
-                    intent.putExtra(FileDownloader.EXTRA_FILE, file);
-                    intent.putExtra(EXTRA_CONFLICT_UPLOAD_ID, conflictUploadId);
-                    startService(intent);
+                    if (!shouldDeleteLocal()) {
+                        // Overwrite local file
+                        Intent intent = new Intent(getBaseContext(), FileDownloader.class);
+                        intent.putExtra(FileDownloader.EXTRA_USER, getUser().orElseThrow(RuntimeException::new));
+                        intent.putExtra(FileDownloader.EXTRA_FILE, file);
+                        intent.putExtra(EXTRA_CONFLICT_UPLOAD_ID, conflictUploadId);
+                        startService(intent);
+                    } else {
+                        uploadsStorageManager.removeUpload(upload);
+                    }
                     break;
             }
 
@@ -240,4 +244,11 @@ public class ConflictsResolveActivity extends FileActivity implements OnConflict
         runOnUiThread(() -> Toast.makeText(this, R.string.conflict_dialog_error, Toast.LENGTH_LONG).show());
         finish();
     }
+
+    /**
+     * @return whether the local version of the files is to be deleted.
+     */
+    private boolean shouldDeleteLocal() {
+        return localBehaviour == FileUploader.LOCAL_BEHAVIOUR_DELETE;
+    }
 }