Skip to content

Commit

Permalink
fix: added variable isActionSynchronize to cover synchronize action
Browse files Browse the repository at this point in the history
  • Loading branch information
Aitorbp committed Jun 13, 2024
1 parent 62a76c5 commit bb9cacf
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,13 @@ class MainFileListFragment : Fragment(),
private fun syncFiles(files: List<OCFile>) {
for (file in files) {
if (file.isFolder) {
fileOperationsViewModel.performOperation(FileOperation.SynchronizeFolderOperation(folderToSync = file, accountName = file.owner))
fileOperationsViewModel.performOperation(
FileOperation.SynchronizeFolderOperation(
folderToSync = file,
accountName = file.owner,
isActionSynchronize = true
)
)
} else {
fileOperationsViewModel.performOperation(FileOperation.SynchronizeFileOperation(fileToSync = file, accountName = file.owner))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ sealed interface FileOperation {
data class RemoveOperation(val listOfFilesToRemove: List<OCFile>, val removeOnlyLocalCopy: Boolean) : FileOperation
data class RenameOperation(val ocFileToRename: OCFile, val newName: String) : FileOperation
data class SynchronizeFileOperation(val fileToSync: OCFile, val accountName: String) : FileOperation
data class SynchronizeFolderOperation(val folderToSync: OCFile, val accountName: String, val isActionSetFolderAvailableOffline: Boolean = false) : FileOperation
data class SynchronizeFolderOperation(
val folderToSync: OCFile,
val accountName: String,
val isActionSetFolderAvailableOffline: Boolean = false,
val isActionSynchronize: Boolean = false
) : FileOperation
data class RefreshFolderOperation(val folderToRefresh: OCFile, val shouldSyncContents: Boolean) : FileOperation
data class CreateFileWithAppProviderOperation(val accountName: String, val parentContainerId: String, val filename: String) : FileOperation
data class SetFilesAsAvailableOffline(val filesToUpdate: List<OCFile>) : FileOperation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ import com.owncloud.android.domain.availableoffline.usecases.SetFilesAsAvailable
import com.owncloud.android.domain.availableoffline.usecases.UnsetFilesAsAvailableOfflineUseCase
import com.owncloud.android.domain.exceptions.NoNetworkConnectionException
import com.owncloud.android.domain.files.model.OCFile
import com.owncloud.android.domain.files.usecases.IsAnyFileAvailableLocallyAndNotAvailableOfflineUseCase
import com.owncloud.android.domain.files.usecases.CopyFileUseCase
import com.owncloud.android.domain.files.usecases.CreateFolderAsyncUseCase
import com.owncloud.android.domain.files.usecases.IsAnyFileAvailableLocallyAndNotAvailableOfflineUseCase
import com.owncloud.android.domain.files.usecases.ManageDeepLinkUseCase
import com.owncloud.android.domain.files.usecases.MoveFileUseCase
import com.owncloud.android.domain.files.usecases.RemoveFileUseCase
Expand Down Expand Up @@ -261,6 +261,7 @@ class FileOperationsViewModel(
spaceId = fileOperation.folderToSync.spaceId,
syncMode = SynchronizeFolderUseCase.SyncFolderMode.SYNC_FOLDER_RECURSIVELY,
isActionSetFolderAvailableOffline = fileOperation.isActionSetFolderAvailableOffline,
isActionSynchronize = fileOperation.isActionSynchronize,
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ private void synchronizeFolder(OCFile folder) {
folder.getOwner(),
folder.getSpaceId(),
SynchronizeFolderUseCase.SyncFolderMode.REFRESH_FOLDER_RECURSIVELY,
false,
false);
UseCaseResult<Unit> useCaseResult;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public void syncFile(OCFile file) {
file.getOwner(),
file.getSpaceId(),
SynchronizeFolderUseCase.SyncFolderMode.SYNC_FOLDER_RECURSIVELY,
false,
false)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class SynchronizeFolderUseCase(
accountName = accountName,
spaceId = params.spaceId,
isActionSetFolderAvailableOffline = params.isActionSetFolderAvailableOffline,
isActionSynchronize = params.isActionSynchronize,
)

folderContent.forEach { ocFile ->
Expand All @@ -54,6 +55,7 @@ class SynchronizeFolderUseCase(
spaceId = ocFile.spaceId,
syncMode = params.syncMode,
isActionSetFolderAvailableOffline = params.isActionSetFolderAvailableOffline,
isActionSynchronize = params.isActionSynchronize
)
)
}
Expand All @@ -79,6 +81,7 @@ class SynchronizeFolderUseCase(
val spaceId: String? = null,
val syncMode: SyncFolderMode,
val isActionSetFolderAvailableOffline: Boolean = false,
val isActionSynchronize: Boolean = false,
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ class OCFileRepository(
accountName: String,
spaceId: String?,
isActionSetFolderAvailableOffline: Boolean,
isActionSynchronize: Boolean,
): List<OCFile> {
val spaceWebDavUrl = localSpacesDataSource.getWebDavUrlForSpace(spaceId, accountName)

Expand Down Expand Up @@ -427,7 +428,8 @@ class OCFileRepository(
})
} else if (localChildToSync.etag != remoteChild.etag ||
localChildToSync.localModificationTimestamp > remoteChild.lastSyncDateForData!! ||
isActionSetFolderAvailableOffline
isActionSetFolderAvailableOffline ||
isActionSynchronize
) {
// File exists in the database, we need to check several stuff.
folderContentUpdated.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ interface FileRepository {
// Returns files in conflict
fun moveFile(listOfFilesToMove: List<OCFile>, targetFolder: OCFile, replace: List<Boolean?> = emptyList(), isUserLogged: Boolean): List<OCFile>
fun readFile(remotePath: String, accountName: String, spaceId: String? = null): OCFile
fun refreshFolder(remotePath: String, accountName: String, spaceId: String? = null, isActionSetFolderAvailableOffline: Boolean = false): List<OCFile>
fun refreshFolder(
remotePath: String,
accountName: String,
spaceId: String? = null,
isActionSetFolderAvailableOffline: Boolean = false,
isActionSynchronize: Boolean = false
): List<OCFile>
fun deleteFiles(listOfFilesToDelete: List<OCFile>, removeOnlyLocalCopy: Boolean)
fun renameFile(ocFile: OCFile, newName: String)
fun saveFile(file: OCFile)
Expand Down

0 comments on commit bb9cacf

Please sign in to comment.