Skip to content

Commit f03f517

Browse files
committed
revert changes due to split prs
Signed-off-by: alperozturk <alper_ozturk@proton.me>
1 parent 3155c65 commit f03f517

4 files changed

Lines changed: 27 additions & 78 deletions

File tree

app/src/main/java/com/nextcloud/client/database/dao/SyncedFolderDao.kt

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
22
* Nextcloud - Android Client
33
*
4-
* SPDX-FileCopyrightText: 2025 Alper Ozturk <alper.ozturk@nextcloud.com>
54
* SPDX-FileCopyrightText: 2022 Álvaro Brey <alvaro@alvarobrey.com>
65
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH
76
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
@@ -11,9 +10,6 @@ package com.nextcloud.client.database.entity
1110
import androidx.room.ColumnInfo
1211
import androidx.room.Entity
1312
import androidx.room.PrimaryKey
14-
import com.nextcloud.client.preferences.SubFolderRule
15-
import com.owncloud.android.datamodel.MediaFolderType
16-
import com.owncloud.android.datamodel.SyncedFolder
1713
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta
1814

1915
@Entity(tableName = ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME)
@@ -54,40 +50,3 @@ data class SyncedFolderEntity(
5450
@ColumnInfo(name = ProviderTableMeta.SYNCED_FOLDER_LAST_SCAN_TIMESTAMP_MS)
5551
val lastScanTimestampMs: Long?
5652
)
57-
58-
fun SyncedFolderEntity.toSyncedFolder(): SyncedFolder = SyncedFolder(
59-
// id
60-
(this.id ?: SyncedFolder.UNPERSISTED_ID).toLong(),
61-
// localPath
62-
this.localPath ?: "",
63-
// remotePath
64-
this.remotePath ?: "",
65-
// wifiOnly
66-
this.wifiOnly == 1,
67-
// chargingOnly
68-
this.chargingOnly == 1,
69-
// existing
70-
this.existing == 1,
71-
// subfolderByDate
72-
this.subfolderByDate == 1,
73-
// account
74-
this.account ?: "",
75-
// uploadAction
76-
this.uploadAction ?: 0,
77-
// nameCollisionPolicy
78-
this.nameCollisionPolicy ?: 0,
79-
// enabled
80-
this.enabled == 1,
81-
// timestampMs
82-
(this.enabledTimestampMs ?: SyncedFolder.EMPTY_ENABLED_TIMESTAMP_MS).toLong(),
83-
// type
84-
MediaFolderType.getById(this.type ?: MediaFolderType.CUSTOM.id),
85-
// hidden
86-
this.hidden == 1,
87-
// subFolderRule
88-
this.subFolderRule?.let { SubFolderRule.entries[it] },
89-
// excludeHidden
90-
this.excludeHidden == 1,
91-
// lastScanTimestampMs
92-
this.lastScanTimestampMs ?: SyncedFolder.NOT_SCANNED_YET
93-
)

app/src/main/java/com/owncloud/android/datamodel/SyncedFolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public SyncedFolder(String localPath,
108108
*
109109
* @param id id
110110
*/
111-
public SyncedFolder(long id,
111+
protected SyncedFolder(long id,
112112
String localPath,
113113
String remotePath,
114114
boolean wifiOnly,

app/src/main/java/com/owncloud/android/datamodel/SyncedFolderProvider.java

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@
1515

1616
import com.nextcloud.client.account.User;
1717
import com.nextcloud.client.core.Clock;
18-
import com.nextcloud.client.database.NextcloudDatabase;
19-
import com.nextcloud.client.database.dao.SyncedFolderDao;
20-
import com.nextcloud.client.database.entity.SyncedFolderEntity;
21-
import com.nextcloud.client.database.entity.SyncedFolderEntityKt;
2218
import com.nextcloud.client.preferences.AppPreferences;
2319
import com.nextcloud.client.preferences.AppPreferencesImpl;
2420
import com.nextcloud.client.preferences.SubFolderRule;
25-
import com.owncloud.android.MainApp;
2621
import com.owncloud.android.db.ProviderMeta;
2722
import com.owncloud.android.lib.common.utils.Log_OC;
2823
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
@@ -47,7 +42,6 @@ public class SyncedFolderProvider extends Observable {
4742
private final ContentResolver mContentResolver;
4843
private final AppPreferences preferences;
4944
private final Clock clock;
50-
public final SyncedFolderDao dao = NextcloudDatabase.getInstance(MainApp.getAppContext()).syncedFolderDao();
5145

5246
/**
5347
* constructor.
@@ -189,11 +183,33 @@ public int updateSyncedFolderEnabled(long id, Boolean enabled) {
189183
}
190184

191185
public SyncedFolder findByLocalPathAndAccount(String localPath, User user) {
192-
final SyncedFolderEntity entity = dao.findByLocalPathAndAccount(localPath, user.getAccountName());
193-
if (entity == null) {
194-
return null;
186+
SyncedFolder result = null;
187+
Cursor cursor = mContentResolver.query(
188+
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
189+
null,
190+
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH + " LIKE ? AND " +
191+
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " =? ",
192+
new String[]{localPath + "%", user.getAccountName()},
193+
null
194+
);
195+
196+
if (cursor != null && cursor.getCount() == 1) {
197+
result = createSyncedFolderFromCursor(cursor);
198+
} else {
199+
if (cursor == null) {
200+
Log_OC.e(TAG, "Sync folder db cursor for local path=" + localPath + " in NULL.");
201+
} else {
202+
Log_OC.e(TAG, cursor.getCount() + " items for local path=" + localPath
203+
+ " available in sync folder db. Expected 1. Failed to update sync folder db.");
204+
}
205+
}
206+
207+
if (cursor != null) {
208+
cursor.close();
195209
}
196-
return SyncedFolderEntityKt.toSyncedFolder(entity);
210+
211+
return result;
212+
197213
}
198214

199215
@Nullable

0 commit comments

Comments
 (0)