Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ interface BackgroundJobManager {

fun startNotificationJob(subject: String, signature: String)
fun startAccountRemovalJob(accountName: String, remoteWipe: Boolean)
fun startFilesUploadJob(user: User, uploadIds: LongArray, showSameFileAlreadyExistsNotification: Boolean)
fun startFilesUploadJob(
user: User,
uploadIds: LongArray,
showSameFileAlreadyExistsNotification: Boolean,
skipAutoUploadCheck: Boolean = false
)
fun getFileUploads(user: User): LiveData<List<JobInfo>>
fun cancelFilesUploadJob(user: User)
fun isStartFileUploadJobScheduled(accountName: String): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,12 @@ internal class BackgroundJobManagerImpl(
* and cannot be determined directly from the account name or a single function
* within the worker.
*/
override fun startFilesUploadJob(user: User, uploadIds: LongArray, showSameFileAlreadyExistsNotification: Boolean) {
override fun startFilesUploadJob(
user: User,
uploadIds: LongArray,
showSameFileAlreadyExistsNotification: Boolean,
skipAutoUploadCheck: Boolean
) {
defaultDispatcherScope.launch {
val batchSize = FileUploadHelper.MAX_FILE_COUNT
val batches = uploadIds.toList().chunked(batchSize)
Expand All @@ -637,6 +642,7 @@ internal class BackgroundJobManagerImpl(
FileUploadWorker.SHOW_SAME_FILE_ALREADY_EXISTS_NOTIFICATION,
showSameFileAlreadyExistsNotification
)
.putBoolean(FileUploadWorker.SKIP_AUTO_UPLOAD_CHECK, skipAutoUploadCheck)
.putString(FileUploadWorker.ACCOUNT, user.accountName)
.putInt(FileUploadWorker.TOTAL_UPLOAD_SIZE, uploadIds.size)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,14 @@ class FileUploadHelper {
}
}

@JvmOverloads
fun uploadUpdatedFile(
user: User,
existingFiles: Array<OCFile?>?,
existingFiles: Array<OCFile?>,
behaviour: Int,
nameCollisionPolicy: NameCollisionPolicy
nameCollisionPolicy: NameCollisionPolicy,
skipAutoUploadCheck: Boolean = false
) {
if (existingFiles == null) {
return
}

Log_OC.d(this, "upload updated file")

val uploads = existingFiles.map { file ->
Expand Down Expand Up @@ -496,7 +494,12 @@ class FileUploadHelper {
}
}
val uploadIds: LongArray = uploads.filterNotNull().map { it.uploadId }.toLongArray()
backgroundJobManager.startFilesUploadJob(user, uploadIds, true)
backgroundJobManager.startFilesUploadJob(
user,
uploadIds,
true,
skipAutoUploadCheck
)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class FileUploadWorker(
const val CURRENT_BATCH_INDEX = "batch_index"
const val TOTAL_UPLOAD_SIZE = "total_upload_size"
const val SHOW_SAME_FILE_ALREADY_EXISTS_NOTIFICATION = "show_same_file_already_exists_notification"

const val SKIP_AUTO_UPLOAD_CHECK = "skip_auto_upload_check"
private const val BATCH_SIZE = 100

const val EXTRA_ACCOUNT_NAME = "ACCOUNT_NAME"
Expand Down Expand Up @@ -234,6 +234,8 @@ class FileUploadWorker(
return@withContext Result.failure()
}

val skipAutoUploadCheck = inputData.getBoolean(SKIP_AUTO_UPLOAD_CHECK, false)

val user = optionalUser.get()
val previouslyUploadedFileSize = currentBatchIndex * FileUploadHelper.MAX_FILE_COUNT
val uploads = uploadsStorageManager.getUploadsByIds(uploadIds, accountName)
Expand All @@ -245,7 +247,7 @@ class FileUploadWorker(
for ((index, upload) in uploads.withIndex()) {
ensureActive()

if (isBelongToAnySyncedFolder(upload, syncFolderHelper, syncedFolders)) {
if (!skipAutoUploadCheck && isBelongToAnySyncedFolder(upload, syncFolderHelper, syncedFolders)) {
Log_OC.d(TAG, "skipping upload, will be handled by AutoUploadWorker: ${upload.localPath}")
uploadsStorageManager.uploadDao.deleteByRemotePathAndAccountName(
remotePath = upload.remotePath,
Expand Down Expand Up @@ -445,7 +447,7 @@ class FileUploadWorker(
if (accountName != null && remotePath != null) {
val key: String = FileUploadHelper.buildRemoteName(accountName, remotePath)
val boundListener = FileUploadHelper.mBoundListeners[key]
val filename = currentUploadFileOperation?.fileName ?: ""
val filename = currentUploadFileOperation.fileName ?: ""

boundListener?.onTransferProgress(
progressRate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ class ConflictsResolveActivity :

private fun handleFile(file: OCFile?, upload: OCUpload?, user: User, policy: NameCollisionPolicy) {
upload?.let { uploadHelper.removeFileUpload(it.remotePath, it.accountName) }
uploadHelper.uploadUpdatedFile(user, arrayOf(file), localBehaviour, policy)
uploadHelper.uploadUpdatedFile(
user,
arrayOf(file),
localBehaviour,
policy,
skipAutoUploadCheck = true
)
}

private suspend fun keepServer(file: OCFile?, upload: OCUpload?, user: User) {
Expand Down
Loading