Rebase master

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2023-12-29 09:05:52 +01:00 committed by Alper Öztürk
parent ce77997033
commit 285e6ac8ed
5 changed files with 12 additions and 69 deletions

View file

@ -80,19 +80,6 @@ class FileDownloadHelper {
storageManager?.saveConflict(file, null)
}
fun downloadFiles(user: User, ocFile: List<OCFile>, cancelRequest: AtomicBoolean) {
backgroundJobManager.startFilesDownloadJob(
user,
ocFile,
"",
DownloadType.DOWNLOAD,
"",
"",
null,
cancelRequest
)
}
fun downloadFile(user: User, ocFile: OCFile) {
backgroundJobManager.startFileDownloadJob(
user,

View file

@ -34,8 +34,10 @@ import androidx.work.WorkerParameters
import com.google.gson.Gson
import com.nextcloud.client.account.User
import com.nextcloud.client.account.UserAccountManager
import com.nextcloud.client.jobs.BackgroundJobManagerImpl.Companion.JOB_FILES_DOWNLOAD
import com.nextcloud.client.notifications.download.DownloadNotificationManager
import com.nextcloud.java.util.Optional
import com.nextcloud.utils.extensions.isWorkScheduled
import com.owncloud.android.datamodel.FileDataStorageManager
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.datamodel.UploadsStorageManager

View file

@ -150,18 +150,6 @@ interface BackgroundJobManager {
fun isStartFileDownloadJobScheduled(user: User, file: OCFile): Boolean
@Suppress("LongParameterList")
fun startFilesDownloadJob(
user: User,
files: List<OCFile>,
behaviour: String,
downloadType: DownloadType?,
activityName: String,
packageName: String,
conflictUploadId: Long?,
cancelRequest: AtomicBoolean
)
@Suppress("LongParameterList")
fun startFileDownloadJob(
user: User,

View file

@ -43,12 +43,10 @@ import com.nextcloud.client.files.downloader.FileDownloadWorker
import com.nextcloud.client.preferences.AppPreferences
import com.nextcloud.utils.extensions.isWorkScheduled
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.lib.common.operations.OperationCancelledException
import com.owncloud.android.operations.DownloadType
import java.util.Date
import java.util.UUID
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicBoolean
import kotlin.reflect.KClass
/**
@ -547,46 +545,6 @@ internal class BackgroundJobManagerImpl(
return workManager.isWorkScheduled(startFileDownloadJobTag(user, file))
}
@Throws(OperationCancelledException::class)
override fun startFilesDownloadJob(
user: User,
files: List<OCFile>,
behaviour: String,
downloadType: DownloadType?,
activityName: String,
packageName: String,
conflictUploadId: Long?,
cancelRequest: AtomicBoolean
) {
val workRequestList = mutableListOf<OneTimeWorkRequest>()
for (file in files) {
synchronized(cancelRequest) {
if (cancelRequest.get()) {
throw OperationCancelledException()
}
workRequestList.add(
getOneTimeDownloadRequest(
user,
file,
behaviour,
downloadType,
activityName,
packageName,
conflictUploadId
)
)
}
}
val chain = workManager
.beginWith(workRequestList.first())
.then(workRequestList.subList(1, workRequestList.size))
chain.enqueue()
}
override fun startFileDownloadJob(
user: User,
ocFile: OCFile,

View file

@ -444,9 +444,17 @@ public class SynchronizeFolderOperation extends SyncOperation {
startContentSynchronizations(mFilesToSyncContents);
}
private void startDirectDownloads() {
private void startDirectDownloads() throws OperationCancelledException {
FileDownloadHelper downloadHelper = new FileDownloadHelper();
downloadHelper.downloadFiles(user, mFilesForDirectDownload, mCancellationRequested);
for (OCFile file : mFilesForDirectDownload) {
synchronized(mCancellationRequested) {
if (mCancellationRequested.get()) {
throw new OperationCancelledException();
}
downloadHelper.downloadFile(user, file);
}
}
}
/**