Skip to content

Commit 9bb77d3

Browse files
authored
Merge pull request #4657 from owncloud/fix/removed_files_in_failed_uploads
[FIX] Removed files in failed uploads
2 parents 949a13f + 45e1332 commit 9bb77d3

File tree

7 files changed

+47
-9
lines changed

7 files changed

+47
-9
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Table of Contents
22

3+
* [Changelog for unreleased](#changelog-for-owncloud-android-client-unreleased-unreleased)
34
* [Changelog for 4.6.1](#changelog-for-owncloud-android-client-461-2025-08-01)
45
* [Changelog for 4.6.0](#changelog-for-owncloud-android-client-460-2025-07-22)
56
* [Changelog for 4.5.1](#changelog-for-owncloud-android-client-451-2025-04-03)
@@ -28,6 +29,27 @@
2829
* [Changelog for 2.18.1](#changelog-for-owncloud-android-client-2181-2021-07-20)
2930
* [Changelog for 2.18.0](#changelog-for-owncloud-android-client-2180-2021-05-24)
3031
* [Changelog for 2.17 versions and below](#changelog-for-217-versions-and-below)
32+
# Changelog for ownCloud Android Client [unreleased] (UNRELEASED)
33+
34+
The following sections list the changes in ownCloud Android Client unreleased relevant to
35+
ownCloud admins and users.
36+
37+
[unreleased]: https://github.com/owncloud/android/compare/v4.6.1...master
38+
39+
## Summary
40+
41+
* Bugfix - Removed files in failed uploads: [#4653](https://github.com/owncloud/android/issues/4653)
42+
43+
## Details
44+
45+
* Bugfix - Removed files in failed uploads: [#4653](https://github.com/owncloud/android/issues/4653)
46+
47+
Files have been prevented from being deleted from the source folder on upload
48+
retries by using the createdBy property.
49+
50+
https://github.com/owncloud/android/issues/4653
51+
https://github.com/owncloud/android/pull/4657
52+
3153
# Changelog for ownCloud Android Client [4.6.1] (2025-08-01)
3254

3355
The following sections list the changes in ownCloud Android Client 4.6.1 relevant to

changelog/unreleased/4657

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Bugfix: Removed files in failed uploads
2+
3+
Files have been prevented from being deleted from the source folder on upload retries by using the createdBy property.
4+
5+
https://github.com/owncloud/android/issues/4653
6+
https://github.com/owncloud/android/pull/4657

owncloudApp/src/main/java/com/owncloud/android/providers/FileContentProvider.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
* @author Christian Schabesberger
99
* @author Abel García de Prada
1010
* @author Juan Carlos Garrote Gascón
11+
* @author Jorge Aguado Recio
1112
*
1213
* Copyright (C) 2011 Bartek Przybylski
13-
* Copyright (C) 2022 ownCloud GmbH.
14+
* Copyright (C) 2025 ownCloud GmbH.
1415
*
1516
* This program is free software: you can redistribute it and/or modify
1617
* it under the terms of the GNU General Public License version 2,
@@ -1077,7 +1078,8 @@ class FileContentProvider(val executors: Executors = Executors()) : ContentProvi
10771078
lastModifiedInSeconds = localFile.lastModified().div(1_000).toString(),
10781079
behavior = UploadBehavior.MOVE.toString(),
10791080
uploadPath = upload.remotePath,
1080-
uploadIdInStorageManager = upload.id
1081+
uploadIdInStorageManager = upload.id,
1082+
createdBy = UploadEnqueuedBy.ENQUEUED_BY_USER
10811083
)
10821084
)
10831085
}

owncloudApp/src/main/java/com/owncloud/android/usecases/transfers/uploads/RetryUploadFromSystemUseCase.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
* @author Abel García de Prada
55
* @author Juan Carlos Garrote Gascón
66
* @author Aitor Ballesteros Pavón
7+
* @author Jorge Aguado Recio
78
*
8-
* Copyright (C) 2024 ownCloud GmbH.
9+
* Copyright (C) 2025 ownCloud GmbH.
910
* <p>
1011
* This program is free software: you can redistribute it and/or modify
1112
* it under the terms of the GNU General Public License version 2,
@@ -60,7 +61,8 @@ class RetryUploadFromSystemUseCase(
6061
behavior = uploadToRetry.localBehaviour.name,
6162
uploadPath = uploadToRetry.remotePath,
6263
sourcePath = uploadToRetry.sourcePath,
63-
uploadIdInStorageManager = params.uploadIdInStorageManager
64+
uploadIdInStorageManager = params.uploadIdInStorageManager,
65+
createdBy = uploadToRetry.createdBy
6466
)
6567
)
6668
} else {

owncloudApp/src/main/java/com/owncloud/android/usecases/transfers/uploads/UploadFileFromSystemUseCase.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
*
44
* @author Juan Carlos Garrote Gascón
55
* @author Aitor Ballesteros Pavón
6+
* @author Jorge Aguado Recio
67
*
7-
* Copyright (C) 2024 ownCloud GmbH.
8+
* Copyright (C) 2025 ownCloud GmbH.
89
* <p>
910
* This program is free software: you can redistribute it and/or modify
1011
* it under the terms of the GNU General Public License version 2,
@@ -28,6 +29,7 @@ import androidx.work.WorkManager
2829
import androidx.work.workDataOf
2930
import com.owncloud.android.domain.BaseUseCase
3031
import com.owncloud.android.domain.automaticuploads.model.UploadBehavior
32+
import com.owncloud.android.domain.transfers.model.UploadEnqueuedBy
3133
import com.owncloud.android.workers.RemoveSourceFileWorker
3234
import com.owncloud.android.workers.UploadFileFromContentUriWorker
3335
import com.owncloud.android.workers.UploadFileFromFileSystemWorker
@@ -62,7 +64,8 @@ class UploadFileFromSystemUseCase(
6264
.build()
6365

6466
val behavior = UploadBehavior.fromString(params.behavior)
65-
if (behavior == UploadBehavior.MOVE) {
67+
val createdBy = params.createdBy
68+
if (behavior == UploadBehavior.MOVE && createdBy != UploadEnqueuedBy.ENQUEUED_BY_USER) {
6669
val removeSourceFileWorker = OneTimeWorkRequestBuilder<RemoveSourceFileWorker>()
6770
.setInputData(inputDataRemoveSourceFileWorker)
6871
.build()
@@ -84,5 +87,6 @@ class UploadFileFromSystemUseCase(
8487
val uploadPath: String,
8588
val uploadIdInStorageManager: Long,
8689
val sourcePath: String? = null,
90+
val createdBy: UploadEnqueuedBy,
8791
)
8892
}

owncloudApp/src/main/java/com/owncloud/android/usecases/transfers/uploads/UploadFilesFromSystemUseCase.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
*
44
* @author Abel García de Prada
55
* @author Juan Carlos Garrote Gascón
6+
* @author Jorge Aguado Recio
67
*
7-
* Copyright (C) 2023 ownCloud GmbH.
8+
* Copyright (C) 2025 ownCloud GmbH.
89
* <p>
910
* This program is free software: you can redistribute it and/or modify
1011
* it under the terms of the GNU General Public License version 2,
@@ -108,7 +109,8 @@ class UploadFilesFromSystemUseCase(
108109
lastModifiedInSeconds = lastModifiedInSeconds,
109110
behavior = UploadBehavior.MOVE.toString(),
110111
uploadPath = uploadPath,
111-
uploadIdInStorageManager = uploadIdInStorageManager
112+
uploadIdInStorageManager = uploadIdInStorageManager,
113+
createdBy = UploadEnqueuedBy.ENQUEUED_BY_USER
112114
)
113115
uploadFileFromSystemUseCase(uploadFileParams)
114116
}

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/ChunkedUploadFromFileSystemOperation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class ChunkedUploadFromFileSystemOperation(
102102
Timber.d("Upload of $localPath to $remotePath, chunk index $chunkIndex, count $chunkCount, HTTP result status $status")
103103

104104
if (isSuccess(status)) {
105-
result = RemoteOperationResult<Unit>(ResultCode.OK)
105+
result = RemoteOperationResult<Unit>(ResultCode.OK).apply { data = Unit }
106106
} else {
107107
result = RemoteOperationResult<Unit>(putMethod)
108108
break

0 commit comments

Comments
 (0)