mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 22:25:44 +03:00
Check parent folder
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
11cc3cdc63
commit
45ca46557a
1 changed files with 9 additions and 3 deletions
|
@ -362,7 +362,7 @@ class FileUploadHelper {
|
||||||
* Removes any existing file in the same directory that has the same name as the provided new file.
|
* Removes any existing file in the same directory that has the same name as the provided new file.
|
||||||
*
|
*
|
||||||
* This function checks the parent directory of the given `newFile` for any file with the same name.
|
* This function checks the parent directory of the given `newFile` for any file with the same name.
|
||||||
* If such a file is found, it is removed using the `fileOperationsHelper`.
|
* If such a file is found, it is removed using the `RemoveFileOperation`.
|
||||||
*
|
*
|
||||||
* @param newFile The new file that is being added to the directory.
|
* @param newFile The new file that is being added to the directory.
|
||||||
* @param clientFactory Needed for creating client
|
* @param clientFactory Needed for creating client
|
||||||
|
@ -375,8 +375,14 @@ class FileUploadHelper {
|
||||||
user: User,
|
user: User,
|
||||||
onCompleted: () -> Unit
|
onCompleted: () -> Unit
|
||||||
) {
|
) {
|
||||||
val parentFile: OCFile? = fileStorageManager.getFileById(newFile.parentId)
|
val parentFolder: OCFile? = fileStorageManager.getFileById(newFile.parentId)
|
||||||
val folderContent: List<OCFile> = fileStorageManager.getFolderContent(parentFile, false)
|
|
||||||
|
if (parentFolder == null) {
|
||||||
|
onCompleted()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val folderContent: List<OCFile> = fileStorageManager.getFolderContent(parentFolder, false)
|
||||||
val duplicatedFile = folderContent.firstOrNull { it.fileName == newFile.fileName }
|
val duplicatedFile = folderContent.firstOrNull { it.fileName == newFile.fileName }
|
||||||
|
|
||||||
if (duplicatedFile == null) {
|
if (duplicatedFile == null) {
|
||||||
|
|
Loading…
Reference in a new issue