Skip to content

Commit

Permalink
Add rename support for file itself
Browse files Browse the repository at this point in the history
  • Loading branch information
alperozturk96 committed Sep 2, 2024
1 parent 711fad7 commit 617dd6e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class OfflineOperationsWorker(

@Suppress("TooGenericExceptionCaught")
override suspend fun doWork(): Result = coroutineScope {
// fileDataStorageManager.offlineOperationDao.clearTable()
val jobName = inputData.getString(JOB_NAME)
Log_OC.d(
TAG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package com.nextcloud.model
sealed class OfflineOperationType {
abstract val type: String

data class CreateFolder(override val type: String, val path: String) : OfflineOperationType()
data class CreateFolder(override val type: String, var path: String) : OfflineOperationType()
data class CreateFile(
override val type: String,
val localPath: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public void deleteOfflineOperation(OCFile file) {
offlineOperationsRepository.deleteOperation(file);
}

public void renameCreateFolderOfflineOperation(OCFile file, String newFolderName) {
public void renameOfflineOperation(OCFile file, String newFolderName) {
var entity = offlineOperationDao.getByPath(file.getDecryptedRemotePath());
if (entity == null) {
return;
Expand All @@ -219,8 +219,13 @@ public void renameCreateFolderOfflineOperation(OCFile file, String newFolderName

String newPath = parentFolder.getDecryptedRemotePath() + newFolderName + OCFile.PATH_SEPARATOR;

OfflineOperationType.CreateFolder operationType = new OfflineOperationType.CreateFolder(OfflineOperationRawType.CreateFolder.name(), newPath);
entity.setType(operationType);
if (entity.getType() instanceof OfflineOperationType.CreateFolder createFolderType) {
createFolderType.setPath(newPath);
} else if (entity.getType() instanceof OfflineOperationType.CreateFile createFileType) {
createFileType.setRemotePath(newPath);
}
entity.setType(entity.getType());

entity.setPath(newPath);
entity.setFilename(newFolderName);
offlineOperationDao.update(entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class RenameFileDialogFragment : DialogFragment(), DialogInterface.OnClickListen
}

if (mTargetFile?.isOfflineOperation == true) {
fileDataStorageManager.renameCreateFolderOfflineOperation(mTargetFile, newFileName)
fileDataStorageManager.renameOfflineOperation(mTargetFile, newFileName)
if (requireActivity() is FileDisplayActivity) {
val activity = requireActivity() as FileDisplayActivity
activity.refreshCurrentDirectory()
Expand Down

0 comments on commit 617dd6e

Please sign in to comment.