Skip to content

Commit 9ffecce

Browse files
committed
sync folder operation already handles nested files
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
1 parent 660b2ff commit 9ffecce

File tree

2 files changed

+1
-50
lines changed

2 files changed

+1
-50
lines changed

app/src/main/java/com/nextcloud/client/jobs/folderDownload/FolderDownloadWorker.kt

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,14 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager
1212
import androidx.work.CoroutineWorker
1313
import androidx.work.ForegroundInfo
1414
import androidx.work.WorkerParameters
15-
import com.nextcloud.client.account.User
1615
import com.nextcloud.client.account.UserAccountManager
1716
import com.nextcloud.client.jobs.download.FileDownloadHelper
1817
import com.owncloud.android.datamodel.FileDataStorageManager
1918
import com.owncloud.android.datamodel.OCFile
20-
import com.owncloud.android.lib.common.OwnCloudClient
2119
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
2220
import com.owncloud.android.lib.common.utils.Log_OC
2321
import com.owncloud.android.operations.DownloadFileOperation
2422
import com.owncloud.android.operations.DownloadType
25-
import com.owncloud.android.operations.RefreshFolderOperation
2623
import com.owncloud.android.utils.FileStorageUtils
2724
import com.owncloud.android.utils.theme.ViewThemeUtils
2825
import kotlinx.coroutines.Dispatchers
@@ -101,8 +98,6 @@ class FolderDownloadWorker(
10198
notificationManager.showNotAvailableDiskSpace()
10299
return@withContext Result.failure()
103100
}
104-
Log_OC.d(TAG, "🔄 syncing full folder tree from server before collecting files")
105-
syncFolderRecursivelyFromServer(folder, user, client)
106101
}
107102

108103
val files = getFiles(folder, storageManager, syncAll)
@@ -175,50 +170,6 @@ class FolderDownloadWorker(
175170
}
176171
}
177172

178-
private fun syncFolderRecursivelyFromServer(folder: OCFile, user: User, client: OwnCloudClient) {
179-
if (isStopped) return
180-
181-
try {
182-
Log_OC.d(TAG, "🔄 refreshing from server: ${folder.remotePath}")
183-
184-
val operation = RefreshFolderOperation(
185-
folder,
186-
System.currentTimeMillis(),
187-
false,
188-
true,
189-
false,
190-
storageManager,
191-
user,
192-
context
193-
)
194-
195-
val result = operation.execute(client)
196-
197-
if (!result.isSuccess) {
198-
Log_OC.w(TAG, "⚠️ failed to refresh ${folder.remotePath}: ${result.logMessage}")
199-
return
200-
}
201-
202-
val refreshedFolder = storageManager.getFileById(folder.fileId) ?: run {
203-
Log_OC.w(TAG, "⚠️ folder ${folder.fileId} missing from DB after refresh")
204-
return
205-
}
206-
207-
val subFolders = storageManager
208-
.getFolderContent(refreshedFolder, false)
209-
.filter { it.isFolder }
210-
211-
for (subFolder in subFolders) {
212-
if (isStopped) return
213-
syncFolderRecursivelyFromServer(subFolder, user, client)
214-
}
215-
} catch (e: Exception) {
216-
Log_OC.w(TAG, "⚠️ exception syncing ${folder.remotePath}: $e")
217-
} finally {
218-
Log_OC.d(TAG, "sub folders are fetched before downloading all")
219-
}
220-
}
221-
222173
@Suppress("ReturnCount")
223174
override suspend fun getForegroundInfo(): ForegroundInfo {
224175
return try {

app/src/main/java/com/nextcloud/ui/fileactions/FileAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ enum class FileAction(
9797
PIN_TO_HOMESCREEN,
9898
RETRY
9999
).apply {
100-
if (files.size == 1 && files.first().isFolder) {
100+
if (files.size == 1 && files.first().isFolder && !files.first().isEncrypted) {
101101
add(DOWNLOAD_ALL_FOLDERS)
102102
}
103103

0 commit comments

Comments
 (0)