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

#7815 Delayed synchronization #11278

Open
wants to merge 95 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
c3aedb9
# Conflicts:
BatPio Dec 20, 2022
0fd71a2
Delayed synchronization
BatPio Dec 20, 2022
3893d8c
master merge fixes
BatPio Dec 20, 2022
a93c3d7
master merge fixes
BatPio Dec 20, 2022
28766ef
Licences
BatPio Dec 20, 2022
a4d47ec
Fixes
BatPio Dec 20, 2022
e6dfc64
Fixes
BatPio Dec 20, 2022
078c9d4
Tuning
BatPio Jan 11, 2023
c09cd0d
Tuning
BatPio Jan 11, 2023
4709531
Merge fixes
BatPio Jan 19, 2023
3efff03
Rename .java to .kt
BatPio Jan 19, 2023
174b93a
New files converted to Kotlin
BatPio Jan 19, 2023
76a2964
CI hints fixes
BatPio Jan 19, 2023
d1b033f
CI Fixes
BatPio Jan 19, 2023
0572790
CI Fixes
BatPio Jan 19, 2023
31bcf88
Lint fixes
BatPio Jan 20, 2023
adca1d0
CI fixes
BatPio Jan 20, 2023
fde9dcf
Lint fixes
BatPio Jan 20, 2023
5dc55e0
Screenshot test fixes
BatPio Jan 21, 2023
afafa0c
CR fixes
BatPio Jan 26, 2023
367c940
Merge branch 'master' into feature/7815/delayed-synchronization-simpl…
BatPio Jan 26, 2023
c9b92be
master merge fixes
BatPio Jan 26, 2023
9308b11
master merge fixes
BatPio Jan 26, 2023
ff7a64d
Merge branch 'nextcloud:master' into feature/7815/delayed-synchroniza…
BatPio Jan 29, 2023
6b04ab5
Merge branch 'master' into feature/7815/delayed-synchronization-simpl…
BatPio Jan 29, 2023
3d40c3a
Merge remote-tracking branch 'origin/feature/7815/delayed-synchroniza…
BatPio Jan 29, 2023
501d1fe
Update app/src/main/java/com/nextcloud/client/database/entity/SyncedF…
BatPio Mar 8, 2023
a3c03c3
master merge fixes
BatPio Mar 8, 2023
b09ebba
Merge branch 'nextcloud:master' into feature/7815/delayed-synchroniza…
BatPio Mar 8, 2023
d0e2168
fixes
BatPio Mar 8, 2023
846794e
Merge branch 'master' into feature/7815/delayed-synchronization-simpl…
BatPio Apr 17, 2023
b6bbea7
synchronization fix
BatPio Apr 17, 2023
6e06c60
Merge branch 'master' into feature/7815/delayed-synchronization-simpl…
BatPio Apr 20, 2023
317ef6e
Merge branch 'master' into feature/7815/delayed-synchronization-simpl…
BatPio Apr 24, 2023
caf858f
Rename .java to .kt
BatPio Aug 4, 2024
4dab2bf
SyncedFolderPreferencesDialogFragment migration
BatPio Aug 4, 2024
3794f5c
SyncedFolderPreferencesDialogFragment moved dialog
BatPio Aug 4, 2024
94af1c7
Merge branch 'master' into feature/7815/delayed-synchronization-simpl…
BatPio Aug 4, 2024
847ef54
SyncedFolderPreferencesDialogFragment moved dialog
BatPio Aug 4, 2024
a501417
Licence update
BatPio Aug 4, 2024
0efe809
CI fixes
BatPio Aug 4, 2024
3a84661
Fixes
BatPio Aug 4, 2024
53ee162
Merge branch 'refs/heads/master' into feature/7815/delayed-synchroniz…
BatPio Aug 4, 2024
56a9002
@Suppress("TooManyFunctions")
BatPio Aug 5, 2024
cb417f0
Merge branch 'refs/heads/master' into feature/7815/delayed-synchroniz…
BatPio Aug 5, 2024
7b11a43
Merge branch 'refs/heads/master' into feature/7815/delayed-synchroniz…
BatPio Sep 3, 2024
eefb03e
Merged with main
BatPio Sep 3, 2024
6336f88
Merge branch 'refs/heads/master' into feature/7815/delayed-synchroniz…
BatPio Oct 27, 2024
bc83af2
Merged with main
BatPio Oct 27, 2024
954bfc0
Merge branch 'refs/heads/master' into feature/7815/delayed-synchroniz…
BatPio Dec 3, 2024
5f114c4
Merge branch 'master' into feature/7815/delayed-synchronization-simpl…
BatPio Dec 7, 2024
0f8f61e
Merge branch 'master' into feature/7815/delayed-synchronization-simpl…
BatPio Jan 6, 2025
6fda157
Merged with main
BatPio Jan 8, 2025
8547450
Merge branch 'master' into feature/7815/delayed-synchronization-simpl…
BatPio Jan 8, 2025
8adf6fd
Merge branch 'nextcloud:master' into feature/7815/delayed-synchroniza…
BatPio Jan 9, 2025
5252a7e
Merge branch 'master' into feature/7815/delayed-synchronization-simpl…
BatPio Jan 9, 2025
ff490d5
Merge remote-tracking branch 'origin/feature/7815/delayed-synchroniza…
BatPio Jan 9, 2025
190844e
Merge branch 'master' into feature/7815/delayed-synchronization-simpl…
BatPio Jan 10, 2025
fb2f319
# Conflicts:
BatPio Dec 20, 2022
0ddfb81
Delayed synchronization
BatPio Dec 20, 2022
4d34599
master merge fixes
BatPio Dec 20, 2022
31f12f7
Licences
BatPio Dec 20, 2022
6ad722a
Fixes
BatPio Dec 20, 2022
d0c2035
Fixes
BatPio Dec 20, 2022
73bd88c
Tuning
BatPio Jan 11, 2023
945b615
Tuning
BatPio Jan 11, 2023
d7f3d07
Merge fixes
BatPio Jan 19, 2023
8d15e6a
Rename .java to .kt
BatPio Jan 19, 2023
b88c974
New files converted to Kotlin
BatPio Jan 19, 2023
f846b29
CI hints fixes
BatPio Jan 19, 2023
345b2ae
CI Fixes
BatPio Jan 19, 2023
da817ff
CI Fixes
BatPio Jan 19, 2023
3ba21df
Lint fixes
BatPio Jan 20, 2023
cc16e85
CI fixes
BatPio Jan 20, 2023
d9345fd
Lint fixes
BatPio Jan 20, 2023
07c2300
Screenshot test fixes
BatPio Jan 21, 2023
212240a
CR fixes
BatPio Jan 26, 2023
dbf48f0
Update app/src/main/java/com/nextcloud/client/database/entity/SyncedF…
BatPio Mar 8, 2023
ed7397e
Licence update
BatPio Aug 4, 2024
60208db
Fixes
BatPio Aug 4, 2024
ee71275
@Suppress("TooManyFunctions")
BatPio Aug 5, 2024
c5d1853
Merged with main
BatPio Oct 27, 2024
17da386
Fix(l10n): Update translations from Transifex
nextcloud-bot Jan 9, 2025
077101e
Fix(l10n): Update translations from Transifex
nextcloud-bot Jan 9, 2025
1c7534e
Fix(l10n): Update translations from Transifex
nextcloud-bot Jan 9, 2025
c512805
Fix(l10n): Update translations from Transifex
nextcloud-bot Jan 10, 2025
c231a84
revert removing verification
tobiasKaminsky Jan 9, 2025
ea9663d
bump lib
tobiasKaminsky Jan 10, 2025
281bc60
re-add lint check for translation
tobiasKaminsky Jan 9, 2025
ac35fcf
fix(deps): update dependency com.android.tools.build:gradle to v8.8.0
renovate[bot] Jan 10, 2025
3b6eb91
Merge remote-tracking branch 'origin/feature/7815/delayed-synchroniza…
BatPio Jan 10, 2025
8e51872
Fixes after CR
BatPio Jan 10, 2025
4408147
DB automigration
BatPio Jan 10, 2025
0fb4570
Merge branch 'master' into feature/7815/delayed-synchronization-simpl…
BatPio Jan 13, 2025
7778a5c
Merge branch 'master' into feature/7815/delayed-synchronization-simpl…
BatPio Jan 15, 2025
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
1,308 changes: 1,308 additions & 0 deletions app/schemas/com.nextcloud.client.database.NextcloudDatabase/86.json

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void testSyncedFolderDialog() {
"test@https://nextcloud.localhost",
0,
0,
0,
true,
1000,
"Name",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Nextcloud Android client application
*
* @author Piotr Bator
* Copyright (C) 2022 Piotr Bator
* Copyright (C) 2022 Nextcloud GmbH
*
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
*/
package com.owncloud.android.ui.dialog
AlvaroBrey marked this conversation as resolved.
Show resolved Hide resolved

import androidx.annotation.UiThread
import androidx.test.core.app.launchActivity
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isRoot
import com.nextcloud.test.TestActivity
import com.owncloud.android.AbstractIT
import com.owncloud.android.utils.ScreenshotTest
import org.junit.Test
import java.util.concurrent.TimeUnit.DAYS
import java.util.concurrent.TimeUnit.HOURS
import java.util.concurrent.TimeUnit.MINUTES

class DurationPickerDialogFragmentIT : AbstractIT() {

private val testClassName = "com.owncloud.android.ui.dialog.DurationPickerDialogFragmentIT"

@Test
@UiThread
@ScreenshotTest
fun showSyncDelayDurationDialog() {
val initialDuration = DAYS.toMillis(2) + HOURS.toMillis(8) + MINUTES.toMillis(15)

launchActivity<TestActivity>().use { scenario ->
scenario.onActivity { sut ->
val transaction = sut.supportFragmentManager.beginTransaction()

val dialog = DurationPickerDialogFragment.newInstance(
initialDuration,
"Dialog title",
"Hint message"
)
dialog.show(transaction, "DURATION_DIALOG")

onIdleSync {
val screenShotName = createName(testClassName + "_" + "showSyncDelayDurationDialog", "")
onView(isRoot()).check(matches(isDisplayed()))
screenshotViaName(sut, screenShotName)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class SyncedFolderUtilsTest : AbstractIT() {
account.name,
1,
1,
0,
true,
0L,
MediaFolderType.IMAGE,
Expand All @@ -194,6 +195,7 @@ class SyncedFolderUtilsTest : AbstractIT() {
account.name,
1,
1,
0,
true,
0L,
MediaFolderType.IMAGE,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Nextcloud Android client application
*
* @author Piotr Bator
* Copyright (C) 2022 Piotr Bator
* Copyright (C) 2022 Nextcloud GmbH
*
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
*/
package com.owncloud.android.utils
AlvaroBrey marked this conversation as resolved.
Show resolved Hide resolved

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.owncloud.android.utils.TimeUtils.getDurationParts
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import java.util.concurrent.TimeUnit

@RunWith(AndroidJUnit4::class)
class TimeUtilsTest {

@Test
fun shouldGetDurationParts() {
val days = 5
val hours = 10
val minutes = 30
val duration = TimeUnit.DAYS.toMillis(days.toLong()) +
TimeUnit.HOURS.toMillis(hours.toLong()) +
TimeUnit.MINUTES.toMillis(minutes.toLong())

val durationParts = getDurationParts(duration)

assertEquals(days, durationParts.days)
assertEquals(hours, durationParts.hours)
assertEquals(minutes, durationParts.minutes)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ import com.owncloud.android.db.ProviderMeta
AutoMigration(from = 81, to = 82),
AutoMigration(from = 82, to = 83),
AutoMigration(from = 83, to = 84),
AutoMigration(from = 84, to = 85, spec = DatabaseMigrationUtil.DeleteColumnSpec::class)
AutoMigration(from = 84, to = 85, spec = DatabaseMigrationUtil.DeleteColumnSpec::class),
AutoMigration(from = 85, to = 86)
],
exportSchema = true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ data class SyncedFolderEntity(
val uploadAction: Int?,
@ColumnInfo(name = ProviderTableMeta.SYNCED_FOLDER_NAME_COLLISION_POLICY)
val nameCollisionPolicy: Int?,
@ColumnInfo(name = ProviderTableMeta.SYNCED_FOLDER_UPLOAD_DELAY_TIME_MS, defaultValue = "0")
val uploadDelayTimeMs: Long,
@ColumnInfo(name = ProviderTableMeta.SYNCED_FOLDER_TYPE)
val type: Int?,
@ColumnInfo(name = ProviderTableMeta.SYNCED_FOLDER_HIDDEN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
import com.owncloud.android.ui.dialog.ConflictsResolveDialog;
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
import com.owncloud.android.ui.dialog.DurationPickerDialogFragment;
import com.owncloud.android.ui.dialog.ExpirationDatePickerDialogFragment;
import com.owncloud.android.ui.dialog.IndeterminateProgressDialog;
import com.owncloud.android.ui.dialog.LoadingDialog;
Expand Down Expand Up @@ -446,6 +447,9 @@ abstract class ComponentsModule {
@ContributesAndroidInjector
abstract SyncFileNotEnoughSpaceDialogFragment syncFileNotEnoughSpaceDialogFragment();

@ContributesAndroidInjector
abstract DurationPickerDialogFragment durationPickerFragment();

@ContributesAndroidInjector
abstract DashboardWidgetConfigurationActivity dashboardWidgetConfigurationActivity();

Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/com/nextcloud/client/jobs/FilesSyncWork.kt
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,16 @@ class FilesSyncWork(
syncedFolderProvider.updateSyncFolder(syncedFolder)
}

private fun getAllFiles(path: String): Set<File> {
private fun getAllFiles(path: String, maxFileTimestamp: Long?): Set<File> {
return File(path).takeIf { it.exists() }
?.walkTopDown()
?.asSequence()
?.filter { file ->
file.isFile &&
file.exists() &&
isQualifiedFolder(file.parentFile?.path) &&
isFileNameQualifiedForAutoUpload(file.name)
isFileNameQualifiedForAutoUpload(file.name) &&
maxFileTimestamp?.let { it >= file.lastModified() } ?: true
}
?.toSet()
?: emptySet()
Expand Down Expand Up @@ -259,7 +260,13 @@ class FilesSyncWork(
null
}

val files = getAllFiles(syncedFolder.localPath)
val maxFileTimestamp = if (syncedFolder.uploadDelayTimeMs > 0) {
System.currentTimeMillis() - syncedFolder.uploadDelayTimeMs
} else {
null
}

val files = getAllFiles(syncedFolder.localPath, maxFileTimestamp)
if (files.isEmpty()) {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.database.Cursor;
import android.net.Uri;

import com.google.common.collect.ObjectArrays;
import com.owncloud.android.db.ProviderMeta;
import com.owncloud.android.lib.common.utils.Log_OC;

Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/owncloud/android/datamodel/SyncedFolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class SyncedFolder implements Serializable, Cloneable {
private boolean chargingOnly;
private boolean existing;
private boolean subfolderByDate;
private long uploadDelayTimeMs;
private String account;
private int uploadAction;
private int nameCollisionPolicy;
Expand Down Expand Up @@ -74,6 +75,7 @@ public SyncedFolder(String localPath,
String account,
int uploadAction,
int nameCollisionPolicy,
long uploadDelayTimeMs,
boolean enabled,
long timestampMs,
MediaFolderType type,
Expand All @@ -91,6 +93,7 @@ public SyncedFolder(String localPath,
account,
uploadAction,
nameCollisionPolicy,
uploadDelayTimeMs,
enabled,
timestampMs,
type,
Expand All @@ -115,6 +118,7 @@ protected SyncedFolder(long id,
String account,
int uploadAction,
int nameCollisionPolicy,
long uploadDelayTimeMs,
boolean enabled,
long timestampMs,
MediaFolderType type,
Expand All @@ -132,6 +136,7 @@ protected SyncedFolder(long id,
this.account = account;
this.uploadAction = uploadAction;
this.nameCollisionPolicy = nameCollisionPolicy;
this.uploadDelayTimeMs = uploadDelayTimeMs;
this.setEnabled(enabled, timestampMs);
this.type = type;
this.hidden = hidden;
Expand Down Expand Up @@ -200,6 +205,10 @@ public NameCollisionPolicy getNameCollisionPolicy() {
return NameCollisionPolicy.deserialize(nameCollisionPolicy);
}

public long getUploadDelayTimeMs() {
return uploadDelayTimeMs;
}

public boolean isEnabled() {
return this.enabled;
}
Expand Down Expand Up @@ -258,6 +267,10 @@ public void setNameCollisionPolicy(int nameCollisionPolicy) {
this.nameCollisionPolicy = nameCollisionPolicy;
}

public void setUploadDelayTimeMs(long uploadDelayTimeMs) {
this.uploadDelayTimeMs = uploadDelayTimeMs;
}

public void setType(MediaFolderType type) {
this.type = type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public SyncedFolderDisplayItem(long id,
String account,
int uploadAction,
int nameCollisionPolicy,
long uploadDelayTimeMs,
boolean enabled,
long timestampMs,
List<String> filePaths,
Expand All @@ -72,6 +73,7 @@ public SyncedFolderDisplayItem(long id,
account,
uploadAction,
nameCollisionPolicy,
uploadDelayTimeMs,
enabled,
timestampMs,
type,
Expand All @@ -94,6 +96,7 @@ public SyncedFolderDisplayItem(long id,
String account,
int uploadAction,
int nameCollisionPolicy,
long uploadDelayTimeMs,
boolean enabled,
long timestampMs,
String folderName,
Expand All @@ -112,6 +115,7 @@ public SyncedFolderDisplayItem(long id,
account,
uploadAction,
nameCollisionPolicy,
uploadDelayTimeMs,
enabled,
timestampMs,
type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ private SyncedFolder createSyncedFolderFromCursor(Cursor cursor) {
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_EXISTING)) == 1;
boolean subfolderByDate = cursor.getInt(cursor.getColumnIndexOrThrow(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE)) == 1;
long uploadDelayTimeMs = cursor.getLong(cursor.getColumnIndexOrThrow(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_DELAY_TIME_MS));
String accountName = cursor.getString(cursor.getColumnIndexOrThrow(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT));
int uploadAction = cursor.getInt(cursor.getColumnIndexOrThrow(
Expand Down Expand Up @@ -400,6 +402,7 @@ private SyncedFolder createSyncedFolderFromCursor(Cursor cursor) {
accountName,
uploadAction,
nameCollisionPolicy,
uploadDelayTimeMs,
enabled,
enabledTimestampMs,
type,
Expand Down Expand Up @@ -428,6 +431,7 @@ private ContentValues createContentValuesFromSyncedFolder(SyncedFolder syncedFol
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED, syncedFolder.isEnabled());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS, syncedFolder.getEnabledTimestampMs());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.isSubfolderByDate());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_DELAY_TIME_MS, syncedFolder.getUploadDelayTimeMs());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT, syncedFolder.getAccount());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION, syncedFolder.getUploadAction());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_NAME_COLLISION_POLICY,
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/owncloud/android/db/ProviderMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
public class ProviderMeta {
public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 85;
public static final int DB_VERSION = 86;

private ProviderMeta() {
// No instance
Expand Down Expand Up @@ -309,6 +309,7 @@ static public class ProviderTableMeta implements BaseColumns {
public static final String SYNCED_FOLDER_ACCOUNT = "account";
public static final String SYNCED_FOLDER_UPLOAD_ACTION = "upload_option";
public static final String SYNCED_FOLDER_NAME_COLLISION_POLICY = "name_collision_policy";
public static final String SYNCED_FOLDER_UPLOAD_DELAY_TIME_MS = "upload_delay_time_ms";
public static final String SYNCED_FOLDER_HIDDEN = "hidden";
public static final String SYNCED_FOLDER_SUBFOLDER_RULE = "sub_folder_rule";
public static final String SYNCED_FOLDER_EXCLUDE_HIDDEN = "exclude_hidden";
Expand Down
Loading
Loading