Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't Show Failed Upload Message For Same File and Handle Local Behavior #14410

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import com.nextcloud.client.preferences.AppPreferences
import com.nextcloud.model.WorkerState
import com.nextcloud.model.WorkerStateLiveData
import com.nextcloud.utils.extensions.getPercent
import com.nextcloud.utils.extensions.showToast
import com.owncloud.android.R
import com.owncloud.android.datamodel.FileDataStorageManager
import com.owncloud.android.datamodel.ThumbnailsCacheManager
import com.owncloud.android.datamodel.UploadsStorageManager
Expand Down Expand Up @@ -284,7 +282,7 @@ class FileUploadWorker(
context
)
) {
context.showToast(R.string.file_upload_worker_same_file_already_exists)
uploadFileOperation.handleLocalBehaviour()
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ private void updateMetadataForV2(DecryptedFolderMetadataFile metadata, Encryptio

private void completeE2EUpload(RemoteOperationResult result, E2EFiles e2eFiles, OwnCloudClient client) {
if (result.isSuccess()) {
handleSuccessfulUpload(e2eFiles.getTemporalFile(), e2eFiles.getExpectedFile(), e2eFiles.getOriginalFile(), client);
handleLocalBehaviour(e2eFiles.getTemporalFile(), e2eFiles.getExpectedFile(), e2eFiles.getOriginalFile(), client);
} else if (result.getCode() == ResultCode.SYNC_CONFLICT) {
getStorageManager().saveConflict(mFile, mFile.getEtagInConflict());
}
Expand Down Expand Up @@ -1098,7 +1098,7 @@ private RemoteOperationResult normalUpload(OwnCloudClient client) {
}

if (result.isSuccess()) {
handleSuccessfulUpload(temporalFile, expectedFile, originalFile, client);
handleLocalBehaviour(temporalFile, expectedFile, originalFile, client);
} else if (result.getCode() == ResultCode.SYNC_CONFLICT) {
getStorageManager().saveConflict(mFile, mFile.getEtagInConflict());
}
Expand Down Expand Up @@ -1197,10 +1197,31 @@ private RemoteOperationResult checkNameCollision(OCFile parentFile,
return null;
}

private void handleSuccessfulUpload(File temporalFile,
File expectedFile,
File originalFile,
OwnCloudClient client) {
public void handleLocalBehaviour() {
if (user == null || mFile == null || mContext == null) {
Log_OC.d(TAG, "handleLocalBehaviour: user, file, or context is null.");
return;
}

final var client = getClient();
if (client == null) {
Log_OC.d(TAG, "handleLocalBehaviour: client is null");
return;
}

String expectedPath = FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), mFile);
File expectedFile = new File(expectedPath);
File originalFile = new File(mOriginalStoragePath);
String temporalPath = FileStorageUtils.getInternalTemporalPath(user.getAccountName(), mContext) + mFile.getRemotePath();
File temporalFile = new File(temporalPath);

handleLocalBehaviour(temporalFile, expectedFile, originalFile, client);
}

private void handleLocalBehaviour(File temporalFile,
File expectedFile,
File originalFile,
OwnCloudClient client) {
switch (mLocalBehaviour) {
case FileUploadWorker.LOCAL_BEHAVIOUR_FORGET:
default:
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@
<string name="uploader_upload_files_behaviour_only_upload">Keep file in source folder</string>
<string name="uploader_upload_files_behaviour_upload_and_delete_from_source">Delete file from source folder</string>
<string name="file_list_seconds_ago">seconds ago</string>
<string name="file_upload_worker_same_file_already_exists">Same file already exists, no conflict detected</string>
<string name="file_list_live">LIVE</string>
<string name="file_list_empty_headline">No files here</string>
<string name="folder_list_empty_headline">No folders here</string>
Expand Down
Loading