mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 23:28:42 +03:00
Rebase master
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
ce77997033
commit
285e6ac8ed
5 changed files with 12 additions and 69 deletions
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue