From 709d5268b770e15631c070876b5aa382472bd7f4 Mon Sep 17 00:00:00 2001 From: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com> Date: Sat, 24 Oct 2026 18:29:42 +0000 Subject: [PATCH 1/2] fix: avoid a double separator in automatic uploads remote path Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com> --- .../android/workers/AutomaticUploadsWorker.kt | 6 +-- .../model/FolderBackUpConfiguration.kt | 9 ++++ .../model/FolderBackUpConfigurationTest.kt | 46 +++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 owncloudDomain/src/test/java/com/owncloud/android/domain/automaticuploads/model/FolderBackUpConfigurationTest.kt diff --git a/owncloudApp/src/main/java/com/owncloud/android/workers/AutomaticUploadsWorker.kt b/owncloudApp/src/main/java/com/owncloud/android/workers/AutomaticUploadsWorker.kt index 3676e9a1750..2118fc14273 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/workers/AutomaticUploadsWorker.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/workers/AutomaticUploadsWorker.kt @@ -49,7 +49,6 @@ import org.koin.core.component.KoinComponent import org.koin.core.component.inject import timber.log.Timber -import java.io.File import java.util.Date import java.util.concurrent.TimeUnit @@ -144,9 +143,10 @@ class AutomaticUploadsWorker( showNotification(syncType, localPicturesDocumentFiles.size) for (documentFile in localPicturesDocumentFiles) { + val uploadPath = folderBackUpConfiguration.getRemotePathForFile(documentFile.name.orEmpty()) val uploadId = storeInUploadsDatabase( documentFile = documentFile, - uploadPath = folderBackUpConfiguration.uploadPath.plus(File.separator).plus(documentFile.name), + uploadPath = uploadPath, accountName = folderBackUpConfiguration.accountName, behavior = folderBackUpConfiguration.behavior, createdByWorker = when (syncType) { @@ -157,7 +157,7 @@ class AutomaticUploadsWorker( ) enqueueSingleUpload( contentUri = documentFile.uri, - uploadPath = folderBackUpConfiguration.uploadPath.plus(File.separator).plus(documentFile.name), + uploadPath = uploadPath, lastModified = documentFile.lastModified(), behavior = folderBackUpConfiguration.behavior.toString(), accountName = folderBackUpConfiguration.accountName, diff --git a/owncloudDomain/src/main/java/com/owncloud/android/domain/automaticuploads/model/FolderBackUpConfiguration.kt b/owncloudDomain/src/main/java/com/owncloud/android/domain/automaticuploads/model/FolderBackUpConfiguration.kt index fd063b69898..ba60bd7d37e 100644 --- a/owncloudDomain/src/main/java/com/owncloud/android/domain/automaticuploads/model/FolderBackUpConfiguration.kt +++ b/owncloudDomain/src/main/java/com/owncloud/android/domain/automaticuploads/model/FolderBackUpConfiguration.kt @@ -19,6 +19,8 @@ package com.owncloud.android.domain.automaticuploads.model +import java.io.File + data class FolderBackUpConfiguration( val accountName: String, val behavior: UploadBehavior, @@ -34,6 +36,13 @@ data class FolderBackUpConfiguration( val isPictureUploads get() = name == pictureUploadsName val isVideoUploads get() = name == videoUploadsName + /** + * Remote path for a file uploaded to this folder. The upload path may end with a separator + * (folders picked in the app do), so it is trimmed to avoid a double separator. + */ + fun getRemotePathForFile(fileName: String): String = + uploadPath.trimEnd(File.separatorChar) + File.separator + fileName + companion object { const val pictureUploadsName = "Picture uploads" const val videoUploadsName = "Video uploads" diff --git a/owncloudDomain/src/test/java/com/owncloud/android/domain/automaticuploads/model/FolderBackUpConfigurationTest.kt b/owncloudDomain/src/test/java/com/owncloud/android/domain/automaticuploads/model/FolderBackUpConfigurationTest.kt new file mode 100644 index 00000000000..d0cd56736e5 --- /dev/null +++ b/owncloudDomain/src/test/java/com/owncloud/android/domain/automaticuploads/model/FolderBackUpConfigurationTest.kt @@ -0,0 +1,46 @@ +/** + * ownCloud Android client application + * + * Copyright (C) 2026 ownCloud GmbH. + * + * 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. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.owncloud.android.domain.automaticuploads.model + +import com.owncloud.android.testutil.OC_BACKUP +import org.junit.Assert.assertEquals +import org.junit.Test + +class FolderBackUpConfigurationTest { + + @Test + fun `getRemotePathForFile - ok - upload path without trailing separator`() { + val folderBackUpConfiguration = OC_BACKUP.copy(uploadPath = "/Photos") + + assertEquals("/Photos/image.jpg", folderBackUpConfiguration.getRemotePathForFile("image.jpg")) + } + + @Test + fun `getRemotePathForFile - ok - upload path with trailing separator`() { + val folderBackUpConfiguration = OC_BACKUP.copy(uploadPath = "/Photos/") + + assertEquals("/Photos/image.jpg", folderBackUpConfiguration.getRemotePathForFile("image.jpg")) + } + + @Test + fun `getRemotePathForFile - ok - root upload path`() { + val folderBackUpConfiguration = OC_BACKUP.copy(uploadPath = "/") + + assertEquals("/image.jpg", folderBackUpConfiguration.getRemotePathForFile("image.jpg")) + } +} From 6bc0604648921cd6d1ce737a0361bb145c102a35 Mon Sep 17 00:00:00 2001 From: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com> Date: Sat, 24 Oct 2026 20:08:20 +0000 Subject: [PATCH 2/2] chore: add calens file Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com> --- changelog/unreleased/5033 | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 changelog/unreleased/5033 diff --git a/changelog/unreleased/5033 b/changelog/unreleased/5033 new file mode 100644 index 00000000000..adb49b913f3 --- /dev/null +++ b/changelog/unreleased/5033 @@ -0,0 +1,7 @@ +Bugfix: Double separator in automatic uploads remote path + +The remote path of automatic uploads has been fixed so it no longer contains a +double separator when the destination folder path ends with a separator. + +https://github.com/owncloud/android/issues/4451 +https://github.com/owncloud/android/pull/5033