Skip to content

Commit 4a65bfd

Browse files
authored
Merge pull request #4571 from owncloud/fix/duplicated_autouploads
[FIX] Image autoupload uploads images twice under certain conditions
2 parents e971cdd + d5cd00d commit 4a65bfd

File tree

42 files changed

+49
-82
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+49
-82
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ ownCloud admins and users.
3636

3737
## Summary
3838

39+
* Bugfix - Changes in the automatic uploads algorithm to prevent duplications: [#3983](https://github.com/owncloud/android/issues/3983)
3940
* Bugfix - Token request with Bearer returns error: [#4080](https://github.com/owncloud/android/issues/4080)
4041
* Bugfix - Side menu collapses info in landscape: [#4513](https://github.com/owncloud/android/issues/4513)
4142
* Bugfix - Content in Spaces not shown from third-party apps: [#4522](https://github.com/owncloud/android/issues/4522)
@@ -51,6 +52,16 @@ ownCloud admins and users.
5152

5253
## Details
5354

55+
* Bugfix - Changes in the automatic uploads algorithm to prevent duplications: [#3983](https://github.com/owncloud/android/issues/3983)
56+
57+
The timestamp for automatic uploads is now updated at the beginning of the
58+
upload process instead of at the end. Additionally, the filter used in
59+
AutomaticUploadsWorker to select the files to upload has been modified in order
60+
to reduce time and charge when evaluating all files.
61+
62+
https://github.com/owncloud/android/issues/3983
63+
https://github.com/owncloud/android/pull/4571
64+
5465
* Bugfix - Token request with Bearer returns error: [#4080](https://github.com/owncloud/android/issues/4080)
5566

5667
A new condition has been added into the network client to check if the network

changelog/unreleased/4571

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Bugfix: Changes in the automatic uploads algorithm to prevent duplications
2+
3+
The timestamp for automatic uploads is now updated at the beginning of the upload process instead of at the end. Additionally, the filter
4+
used in AutomaticUploadsWorker to select the files to upload has been modified in order to reduce time and charge when evaluating all files.
5+
6+
https://github.com/owncloud/android/issues/3983
7+
https://github.com/owncloud/android/pull/4571

owncloudApp/src/main/java/com/owncloud/android/presentation/releasenotes/ReleaseNotesViewModel.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ class ReleaseNotesViewModel(
4848
subtitle = R.string.release_notes_4_6_0_subtitle_shares_space_docs_provider,
4949
type = ReleaseNoteType.ENHANCEMENT
5050
),
51+
ReleaseNote(
52+
title = R.string.release_notes_4_6_0_title_duplicated_automatic_uploads,
53+
subtitle = R.string.release_notes_4_6_0_subtitle_duplicated_automatic_uploads,
54+
type = ReleaseNoteType.BUGFIX
55+
),
5156
ReleaseNote(
5257
title = R.string.release_notes_bugfixes_title,
5358
subtitle = R.string.release_notes_bugfixes_subtitle,

owncloudApp/src/main/java/com/owncloud/android/presentation/settings/automaticuploads/SettingsPictureUploadsFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class SettingsPictureUploadsFragment : PreferenceFragmentCompat() {
173173
picturesViewModel.enablePictureUploads(selectedAccount)
174174
showAlertDialog(
175175
title = getString(R.string.common_important),
176-
message = getString(R.string.proper_pics_folder_warning_camera_upload)
176+
message = getString(R.string.proper_pics_folder_warning_camera_upload, getString(R.string.app_name))
177177
)
178178
true
179179
} else {

owncloudApp/src/main/java/com/owncloud/android/presentation/settings/automaticuploads/SettingsVideoUploadsFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class SettingsVideoUploadsFragment : PreferenceFragmentCompat() {
171171
videosViewModel.enableVideoUploads(selectedAccount)
172172
showAlertDialog(
173173
title = getString(R.string.common_important),
174-
message = getString(R.string.proper_videos_folder_warning_camera_upload)
174+
message = getString(R.string.proper_videos_folder_warning_camera_upload, getString(R.string.app_name))
175175
)
176176
true
177177
} else {

owncloudApp/src/main/java/com/owncloud/android/workers/AutomaticUploadsWorker.kt

Lines changed: 11 additions & 8 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) 2022 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,
@@ -122,9 +123,7 @@ class AutomaticUploadsWorker(
122123
WorkManager.getInstance(appContext).cancelUniqueWork(AUTOMATIC_UPLOADS_WORKER)
123124
}
124125

125-
private fun syncFolder(folderBackUpConfiguration: FolderBackUpConfiguration?) {
126-
if (folderBackUpConfiguration == null) return
127-
126+
private fun syncFolder(folderBackUpConfiguration: FolderBackUpConfiguration) {
128127
val syncType = when {
129128
folderBackUpConfiguration.isPictureUploads -> SyncType.PICTURE_UPLOADS
130129
folderBackUpConfiguration.isVideoUploads -> SyncType.VIDEO_UPLOADS
@@ -133,6 +132,7 @@ class AutomaticUploadsWorker(
133132
}
134133

135134
val currentTimestamp = System.currentTimeMillis()
135+
updateTimestamp(folderBackUpConfiguration, syncType, currentTimestamp)
136136

137137
val localPicturesDocumentFiles: List<DocumentFile> = getFilesReadyToUpload(
138138
syncType = syncType,
@@ -166,7 +166,6 @@ class AutomaticUploadsWorker(
166166
chargingOnly = folderBackUpConfiguration.chargingOnly
167167
)
168168
}
169-
updateTimestamp(folderBackUpConfiguration, syncType, currentTimestamp)
170169
}
171170

172171
private fun showNotification(
@@ -248,10 +247,14 @@ class AutomaticUploadsWorker(
248247
val arrayOfLocalFiles = documentTree?.listFiles() ?: arrayOf()
249248

250249
val filteredList: List<DocumentFile> = arrayOfLocalFiles
250+
.asSequence()
251+
.filter {
252+
it.lastModified() in lastSyncTimestamp..<currentTimestamp &&
253+
MimetypeIconUtil.getBestMimeTypeByFilename(it.name).startsWith(syncType.prefixForType) &&
254+
!it.name.orEmpty().startsWith(".")
255+
}
251256
.sortedBy { it.lastModified() }
252-
.filter { it.lastModified() >= lastSyncTimestamp }
253-
.filter { it.lastModified() < currentTimestamp }
254-
.filter { MimetypeIconUtil.getBestMimeTypeByFilename(it.name).startsWith(syncType.prefixForType) }
257+
.toList()
255258

256259
Timber.i("Last sync ${syncType.name}: ${Date(lastSyncTimestamp)}")
257260
Timber.i("CurrentTimestamp ${Date(currentTimestamp)}")

owncloudApp/src/main/res/values-ar/strings.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,6 @@
356356
<string name="confirmation_disable_camera_uploads_title">تأكيد</string>
357357
<string name="confirmation_disable_pictures_upload_message">هل أنت متأكد أنك ترغب في تعطيل هذه الميزة؟ لن يتم تحميل الصور المعلقة</string>
358358
<string name="confirmation_disable_videos_upload_message">هل أنت متأكد أنك ترغب في تعطيل هذه الميزة؟ لن يتم تحميل مقاطع الفيديو المعلقة</string>
359-
<string name="proper_pics_folder_warning_camera_upload">يُرجى التأكد من أن المجلد المحدد هو المكان الذي تحفظ فيه الكاميرا التي تستخدمها الصور الملتقطة. وإلا لن تتمكن الميزة من العثور على صورك. يُرجى مراعاة أن عملية تحميل الصور ستتم في غضون 15 دقيقة على الأقل من التقاطها.</string>
360-
<string name="proper_videos_folder_warning_camera_upload">يُرجى التأكد من أن المجلد المحدد هو المكان الذي تحفظ فيه الكاميرا التي تستخدمها مقاطع الفيديو المسجلة. وإلا لن تتمكن الميزة من العثور على مقاطع الفيديو. يُرجى مراعاة أن عملية تحميل مقاطع الفيديو ستتم في غضون 15 دقيقة على الأقل من تسجيلها.</string>
361359
<string name="conflict_description">حدث تعارض في ملف %1$s، انقر لحل هذه المشكلة</string>
362360
<string name="conflict_message">ما الملفات التي ترغب في حفظها؟ إن حددت كلا الإصدارَين، فستتم إضافة رقم إلى اسم الملف المحلي.</string>
363361
<string name="conflict_keep_both">احتفظ بالإصدارين</string>

owncloudApp/src/main/res/values-bg-rBG/strings.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,6 @@
356356
<string name="placeholder_timestamp">2012/05/18 12:23 PM</string>
357357
<string name="placeholder_media_time">12:23:45</string>
358358
<string name="confirmation_disable_camera_uploads_title">Потвърждаване</string>
359-
<string name="proper_pics_folder_warning_camera_upload">Моля уверете се, че избраната папка е мястото където камерата, която използвате запазва направените изображения. В противен случай функцията няма да може да ги открие. Имайте предвид, че изображенията ще бъдат качени най-малко 15 минути след заснемането им.</string>
360-
<string name="proper_videos_folder_warning_camera_upload">Моля уверете се, че избраната папка е мястото където камерата, която използвате запазва записаните видеоклипове. В противен случай функцията няма да може да открие вашите видеоклипове. Имайте предвид, че видеоклиповете ще бъдат качени най-малко 15 минути след записването им.</string>
361359
<string name="conflict_title">Файл в конфликт</string>
362360
<string name="conflict_message">Кои файлове искате да запазите? Ако изберете и двете версии, локалния файл ще има числа добавени към името си.</string>
363361
<string name="conflict_keep_both">Запазване и на двата</string>

owncloudApp/src/main/res/values-ca/strings.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,6 @@
340340
<string name="confirmation_disable_camera_uploads_title">Confirma</string>
341341
<string name="confirmation_disable_pictures_upload_message">Estàs segur que vols desactivar aquesta funció? Les fotos pendents no es carregaran.</string>
342342
<string name="confirmation_disable_videos_upload_message">Estàs segur que vols desactivar aquesta funció? Les fotos pendents no es carregaran.</string>
343-
<string name="proper_pics_folder_warning_camera_upload">Si us plau assegura\'t de que la carpeta que has seleccionat és on la càmara que estàs fent servir guarda les fotografies fetes. En cas contrari l\'aplicació no podrà detectar les vostres imatges. Tingueu en compte que les imatges es penjarant al menys 15 minuts després de fer-les.</string>
344-
<string name="proper_videos_folder_warning_camera_upload">Si us plau assegura\'t de que la carpeta que has seleccionat és on la càmara que estàs fent servir guarda els videos fets. En cas contrari l\'aplicació no podrà detectar els vostres videos. Tingueu en compte que els videos es penjarant al menys 15 minuts després de fer-los.</string>
345343
<string name="conflict_description">Hi ha un conflicte en l\'arxiu 1%1$s, clicka per arreglar-ho</string>
346344
<string name="conflict_message">Quins fitxers vols mantenir? Si seleccioneu les dues versions, el fitxer local tindrà un número afegit al seu nom.</string>
347345
<string name="conflict_keep_both">Mantén-los ambdós</string>

owncloudApp/src/main/res/values-cs-rCZ/strings.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,6 @@
410410
<string name="confirmation_disable_camera_uploads_title">Potvrzení</string>
411411
<string name="confirmation_disable_pictures_upload_message">Opravdu chcete tuto funkci deaktivovat? Nevyřízené obrázky nebudou nahrány.</string>
412412
<string name="confirmation_disable_videos_upload_message">Opravdu chcete tuto funkci deaktivovat? Nevyřízená videa nebudou nahrána.</string>
413-
<string name="proper_pics_folder_warning_camera_upload">Prosím ujistěte se, že vybraná složka obsahuje fotografie pořízené fotoaparátem. Jinak aplikace nebude schopna rozpoznat vaše fotografie. Mějte na paměti, že budou nahrány nejdříve 15 minut po jejich pořízení.</string>
414-
<string name="proper_videos_folder_warning_camera_upload">Prosím ujistěte se, že vybraná složka obsahuje videa pořízená fotoaparátem. Jinak aplikace nebude schopna rozpoznat vaše videa. Mějte na paměti, že budou nahrána nejdříve 15 minut po jejich pořízení.</string>
415413
<string name="conflict_title">Konflikt souboru</string>
416414
<string name="conflict_description">Soubor %1$s obsahuje konflikt, kliknutím na tlačítko jej vyřešíte.</string>
417415
<string name="conflict_message">Které soubory chcete ponechat? Pokud zvolíte obě verze, zkopírovaný soubor bude mít název doplněný o číslo.</string>

0 commit comments

Comments
 (0)