Skip to content
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Summary
* Bugfix - ANR after removing account with too many downloaded files: [#3362](https://github.com/owncloud/android/issues/3362)
* Bugfix - Account removed is not removed from the drawer: [#3340](https://github.com/owncloud/android/issues/3340)
* Bugfix - Crash in FileDataStorageManager: [#2896](https://github.com/owncloud/android/issues/2896)
* Bugfix - Camera Upload manual retry: [#3418](https://github.com/owncloud/android/pull/3418)
* Enhancement - Delete old user directories in order to free memory: [#3336](https://github.com/owncloud/android/pull/3336)
* Enhancement - Delete old logs every week: [#3328](https://github.com/owncloud/android/issues/3328)
* Enhancement - Instant upload only when charging: [#465](https://github.com/owncloud/android/issues/465)
Expand Down Expand Up @@ -63,6 +64,14 @@ Details
https://github.com/owncloud/android/issues/2896
https://github.com/owncloud/android/pull/3383

* Bugfix - Camera Upload manual retry: [#3418](https://github.com/owncloud/android/pull/3418)

Previously, when users selected to retry a single camera upload, an error message appeared.
Now, the retry of a single upload is enqueued again as expected.

https://github.com/owncloud/android/issues/3417
https://github.com/owncloud/android/pull/3418

* Enhancement - Delete old user directories in order to free memory: [#3336](https://github.com/owncloud/android/pull/3336)

Previously, when users deleted an account the synchronized files of this account stayed on the
Expand Down
7 changes: 7 additions & 0 deletions changelog/unreleased/3418
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Camera Upload manual retry

Previously, when users selected to retry a single camera upload, an error message appeared.
Now, the retry of a single upload is enqueued again as expected.

https://github.com/owncloud/android/pull/3418
https://github.com/owncloud/android/issues/3417
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import com.owncloud.android.datamodel.OCUpload;
import com.owncloud.android.datamodel.UploadsStorageManager;
import com.owncloud.android.db.UploadResult;
import com.owncloud.android.usecases.UploadFileFromContentUriUseCase;
import com.owncloud.android.usecases.RetryUploadFromContentUriUseCase;
import com.owncloud.android.utils.ConnectivityUtils;
import com.owncloud.android.utils.Extras;
import com.owncloud.android.utils.PowerUtils;
Expand Down Expand Up @@ -213,7 +213,7 @@ private void retry(Context context, Account account, OCUpload upload, boolean re
}

if (isContentUri(context, upload)) {
enqueueRetry(upload, context);
enqueueRetryFromContentUri(upload, context);
} else {
Intent intent = new Intent(context, FileUploader.class);
intent.putExtra(FileUploader.KEY_RETRY, true);
Expand Down Expand Up @@ -243,17 +243,10 @@ private Boolean isContentUri(Context context, OCUpload upload) {
return DocumentFile.isDocumentUri(context, Uri.parse(upload.getLocalPath()));
}

private void enqueueRetry(OCUpload upload, Context context) {
new UploadFileFromContentUriUseCase(WorkManager.getInstance(context)).execute(
new UploadFileFromContentUriUseCase.Params(
upload.getAccountName(),
Uri.parse(upload.getLocalPath()),
upload.getUploadEndTimestamp() / 1000 + "",
"COPY",
upload.getRemotePath(),
upload.getUploadId(),
false,
false
private void enqueueRetryFromContentUri(OCUpload upload, Context context) {
new RetryUploadFromContentUriUseCase(WorkManager.getInstance(context)).execute(
new RetryUploadFromContentUriUseCase.Params(
upload.getUploadId()
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import androidx.documentfile.provider.DocumentFile;
import androidx.work.WorkManager;
import com.google.android.material.snackbar.Snackbar;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.OCFile;
Expand All @@ -58,6 +59,7 @@
import com.owncloud.android.ui.fragment.OptionsInUploadListClickListener;
import com.owncloud.android.ui.fragment.UploadListFragment;
import com.owncloud.android.usecases.CancelUploadWithIdUseCase;
import com.owncloud.android.usecases.RetryUploadFromContentUriUseCase;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.MimetypeIconUtil;
import com.owncloud.android.utils.PreferenceUtils;
Expand Down Expand Up @@ -396,6 +398,13 @@ public void onClick(View v) {
TransferRequester requester = new TransferRequester();
requester.retry(mParentActivity, upload, false);
refreshView();
} else if (DocumentFile.isDocumentUri(v.getContext(), Uri.parse(upload.getLocalPath()))) {
WorkManager workManager = WorkManager.getInstance(MainApp.Companion.getAppContext());
RetryUploadFromContentUriUseCase retryUploadFromContentUriUseCase = new RetryUploadFromContentUriUseCase(workManager);
RetryUploadFromContentUriUseCase.Params useCaseParams = new RetryUploadFromContentUriUseCase.Params(
upload.getUploadId()
);
retryUploadFromContentUriUseCase.execute(useCaseParams);
} else {
Snackbar snackbar = Snackbar.make(
v.getRootView().findViewById(android.R.id.content),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* ownCloud Android client application
*
* @author Abel García de Prada
* Copyright (C) 2021 ownCloud GmbH.
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.owncloud.android.usecases

import androidx.core.net.toUri
import androidx.work.WorkManager
import com.owncloud.android.MainApp
import com.owncloud.android.datamodel.UploadsStorageManager
import com.owncloud.android.domain.BaseUseCase
import com.owncloud.android.domain.camerauploads.model.FolderBackUpConfiguration.Behavior.COPY
import com.owncloud.android.domain.camerauploads.model.FolderBackUpConfiguration.Behavior.MOVE
import com.owncloud.android.files.services.FileUploader.LOCAL_BEHAVIOUR_MOVE

class RetryUploadFromContentUriUseCase(
private val workManager: WorkManager
) : BaseUseCase<Unit, RetryUploadFromContentUriUseCase.Params>() {

override fun run(params: Params) {

val uploadsStorageManager = UploadsStorageManager(MainApp.appContext.contentResolver)
val failedUploads = uploadsStorageManager.failedUploads
val filteredUploads = failedUploads.filter { it.uploadId == params.uploadIdInStorageManager }
val uploadToRetry = filteredUploads.firstOrNull()

uploadToRetry ?: return

UploadFileFromContentUriUseCase(workManager).execute(
UploadFileFromContentUriUseCase.Params(
accountName = uploadToRetry.accountName,
contentUri = uploadToRetry.localPath.toUri(),
lastModifiedInSeconds = (uploadToRetry.uploadEndTimestamp / 1000).toString(),
behavior = if (uploadToRetry.localAction == LOCAL_BEHAVIOUR_MOVE) MOVE.name else COPY.name,
uploadPath = uploadToRetry.remotePath,
uploadIdInStorageManager = uploadToRetry.uploadId,
wifiOnly = false,
chargingOnly = false
)
)
uploadsStorageManager.updateUpload(uploadToRetry.apply { uploadStatus = UploadsStorageManager.UploadStatus.UPLOAD_IN_PROGRESS })
}

data class Params(
val uploadIdInStorageManager: Long,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.owncloud.android.domain.camerauploads.model.FolderBackUpConfiguration
import com.owncloud.android.domain.camerauploads.usecases.GetCameraUploadsConfigurationUseCase
import com.owncloud.android.domain.camerauploads.usecases.SavePictureUploadsConfigurationUseCase
import com.owncloud.android.domain.camerauploads.usecases.SaveVideoUploadsConfigurationUseCase
import com.owncloud.android.files.services.FileUploader
import com.owncloud.android.operations.UploadFileOperation.CREATED_AS_CAMERA_UPLOAD_PICTURE
import com.owncloud.android.operations.UploadFileOperation.CREATED_AS_CAMERA_UPLOAD_VIDEO
import com.owncloud.android.presentation.ui.settings.SettingsActivity
Expand Down Expand Up @@ -291,7 +292,10 @@ class CameraUploadsWorker(
fileSize = documentFile.length()
isForceOverwrite = false
createdBy = createdByWorker
localAction = behavior.ordinal
localAction = if (behavior == FolderBackUpConfiguration.Behavior.MOVE)
FileUploader.LOCAL_BEHAVIOUR_MOVE
else
FileUploader.LOCAL_BEHAVIOUR_COPY
uploadStatus = UploadStatus.UPLOAD_IN_PROGRESS
}
return uploadStorageManager.storeUpload(ocUpload)
Expand Down