Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b494809
chore(gradle): Improve Gradle Configuration
jim-acn Oct 10, 2025
645481a
chore(gradle): Improve Gradle Configuration
jim-acn Oct 10, 2025
9807c02
chore(gradle): Resolve comment
jim-acn Oct 13, 2025
e77fdcd
chore(gradle): Resolve comment
jim-acn Oct 14, 2025
b9b51c8
paginate: local file list adapter
alperozturk96 Oct 1, 2025
aef2b4a
paginate: local file list adapter
alperozturk96 Oct 1, 2025
d3330a5
paginate: local file list adapter
alperozturk96 Oct 1, 2025
e766ef9
refactor: pagination
alperozturk96 Oct 6, 2025
af452ab
refactor: pagination
alperozturk96 Oct 6, 2025
a740cd6
fix: sorting order
alperozturk96 Oct 6, 2025
c3d5bed
add: file helper tests
alperozturk96 Oct 6, 2025
da8afa7
fix: code analytics
alperozturk96 Oct 6, 2025
a2698d2
fix: local file list duplicate item
alperozturk96 Oct 14, 2025
cfaf825
fix(l10n): Update translations from Transifex
nextcloud-bot Oct 15, 2025
71fcc18
fix: folder download
alperozturk96 Oct 14, 2025
d243293
rename to folder download worker
alperozturk96 Oct 14, 2025
da14449
rename to folder download worker
alperozturk96 Oct 15, 2025
5fdd7db
chore: upgrade android sdk 36
alperozturk96 Oct 6, 2025
a9b76a2
refactor: update back press gesture
alperozturk96 Oct 6, 2025
5628c7b
fix: custom back press navigation
alperozturk96 Oct 6, 2025
945fd35
fix: custom back press navigation
alperozturk96 Oct 6, 2025
0544556
fix: code analytics
alperozturk96 Oct 6, 2025
710bdaa
fix: code analytics
alperozturk96 Oct 6, 2025
d12d3a3
add: Unsupported platform APIs and unable to migrate due to outdated …
alperozturk96 Oct 7, 2025
7714335
fix: back press of fda
alperozturk96 Oct 15, 2025
4e277dd
fix: back press of fda
alperozturk96 Oct 15, 2025
1fa87b9
fix: make file upload worker long running task
alperozturk96 Oct 14, 2025
c3fde61
fix: save file for folder download
alperozturk96 Oct 15, 2025
60866b8
fix: save file for folder download
alperozturk96 Oct 15, 2025
6ad8a98
fix(l10n): Update translations from Transifex
nextcloud-bot Oct 16, 2025
f3b0b8a
fix: handle not modified and no content response
alperozturk96 Oct 15, 2025
e299a74
fix: handle not modified
alperozturk96 Oct 15, 2025
ed06c09
fix: git conflict
alperozturk96 Oct 15, 2025
0696850
fix: upload cancel
alperozturk96 Sep 29, 2025
00c8c7c
fix: upload cancel
alperozturk96 Sep 29, 2025
9b04f37
fix: upload cancel
alperozturk96 Sep 30, 2025
54056b9
fix: upload cancel
alperozturk96 Sep 30, 2025
523f822
fix: upload cancel
alperozturk96 Sep 30, 2025
ee69e98
fix: upload cancel
alperozturk96 Sep 30, 2025
506fbe9
fix: upload cancel
alperozturk96 Sep 30, 2025
0c7317b
fix: upload cancel
alperozturk96 Sep 30, 2025
b8c55bd
fix: upload cancel
alperozturk96 Sep 30, 2025
d0402ae
fix: git conflict
alperozturk96 Oct 15, 2025
60ffc50
chore: update lib
alperozturk96 Oct 15, 2025
fa4efa0
chore(gradle): Resolve conflict
jim-acn Oct 17, 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
Prev Previous commit
Next Next commit
fix: save file for folder download
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 authored and jim-acn committed Oct 17, 2025
commit c3fde6179edf06506bc160073b86ea697a52f234
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import android.content.Context
import androidx.work.CoroutineWorker
import androidx.work.WorkerParameters
import com.nextcloud.client.account.User
import com.nextcloud.client.jobs.download.FileDownloadHelper
import com.owncloud.android.datamodel.FileDataStorageManager
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.lib.common.OwnCloudClient
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
import com.owncloud.android.lib.common.utils.Log_OC
import com.owncloud.android.operations.DownloadFileOperation
import com.owncloud.android.operations.DownloadType
import com.owncloud.android.ui.helpers.FileOperationsHelper
import com.owncloud.android.utils.theme.ViewThemeUtils
import kotlinx.coroutines.Dispatchers
Expand All @@ -41,25 +43,28 @@ class FolderDownloadWorker(
}

private var notificationManager: FolderDownloadWorkerNotificationManager? = null
private lateinit var storageManager: FileDataStorageManager

@Suppress("TooGenericExceptionCaught", "ReturnCount", "DEPRECATION")
override suspend fun doWork(): Result {
val folderID = inputData.getLong(FOLDER_ID, -1)
if (folderID == -1L) {
return Result.failure()
}
val storageManager = FileDataStorageManager(user, context.contentResolver)
storageManager = FileDataStorageManager(user, context.contentResolver)
val folder = storageManager.getFileById(folderID) ?: return Result.failure()

notificationManager = FolderDownloadWorkerNotificationManager(context, viewThemeUtils)

Log_OC.d(TAG, "started")
Log_OC.d(TAG, "🕒 started")

val foregroundInfo = notificationManager?.getForegroundInfo(folder) ?: return Result.failure()
setForeground(foregroundInfo)

pendingDownloads.add(folder.fileId)

val downloadHelper = FileDownloadHelper.instance()

return withContext(Dispatchers.IO) {
try {
val files = getFiles(folder, storageManager)
Expand All @@ -80,8 +85,15 @@ class FolderDownloadWorker(
)
}

val operation = DownloadFileOperation(user, file, context).execute(client)
if (!operation.isSuccess) {
val operation = DownloadFileOperation(user, file, context)
val operationResult = operation.execute(client)
if (operationResult?.isSuccess == true && operation.downloadType === DownloadType.DOWNLOAD) {
getOCFile(operation)?.let { ocFile ->
downloadHelper.saveFile(ocFile, operation, storageManager)
}
}

if (!operationResult.isSuccess) {
result = false
}
}
Expand All @@ -91,14 +103,14 @@ class FolderDownloadWorker(
}

if (result) {
Log_OC.d(TAG, "completed")
Log_OC.d(TAG, "completed")
Result.success()
} else {
Log_OC.d(TAG, "failed")
Log_OC.d(TAG, "failed")
Result.failure()
}
} catch (e: Exception) {
Log_OC.d(TAG, "failed reason: $e")
Log_OC.d(TAG, "failed reason: $e")
Result.failure()
} finally {
pendingDownloads.remove(folder.fileId)
Expand All @@ -107,6 +119,17 @@ class FolderDownloadWorker(
}
}

private fun getOCFile(operation: DownloadFileOperation): OCFile? {
val file = operation.file?.fileId?.let { storageManager.getFileById(it) }
?: storageManager.getFileByDecryptedRemotePath(operation.file?.remotePath)
?: run {
Log_OC.e(TAG, "could not save ${operation.file?.remotePath}")
return null
}

return file
}

private fun getFiles(folder: OCFile, storageManager: FileDataStorageManager): List<OCFile> =
storageManager.getFolderContent(folder, false)
.filter { !it.isFolder && !it.isDown }
Expand Down