From 6e1b54f0498521774d1813429ce0f3262571bdd1 Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Wed, 23 Oct 2024 11:46:27 +0200 Subject: [PATCH] Rename local copy folder into import folder --- .../ui/screen/newtransfer/ImportationFilesManager.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportationFilesManager.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportationFilesManager.kt index 0699ed518..4eee7b8a0 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportationFilesManager.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportationFilesManager.kt @@ -57,8 +57,8 @@ class ImportationFilesManager @Inject constructor(@ApplicationContext private va // the list of already imported files we listen to in the LazyRow. private val alreadyUsedFileNames = AlreadyUsedFileNamesSet() - private val localCopyFolder by lazy { File(appContext.cacheDir, LOCAL_COPY_FOLDER) } - private fun getGetLocalCopyFolderOrCopy() = localCopyFolder.apply { if (!exists()) mkdirs() } + private val importFolder by lazy { File(appContext.cacheDir, LOCAL_COPY_FOLDER) } + private fun getImportFolderOrCreate() = importFolder.apply { if (!exists()) mkdirs() } suspend fun addFiles(uris: List) { uris.extractPickedFiles().forEach { filesToImport.send(it) } @@ -71,13 +71,13 @@ class ImportationFilesManager @Inject constructor(@ApplicationContext private va } fun removeLocalCopyFolder() { - if (localCopyFolder.exists()) runCatching { localCopyFolder.deleteRecursively() } + if (importFolder.exists()) runCatching { importFolder.deleteRecursively() } } suspend fun restoreAlreadyImportedFiles() { - if (!localCopyFolder.exists()) return + if (!importFolder.exists()) return - val alreadyCopiedFiles = localCopyFolder.listFiles() ?: return + val alreadyCopiedFiles = importFolder.listFiles() ?: return val restoredFileData = getRestoredFileData(alreadyCopiedFiles) if (alreadyCopiedFiles.size != restoredFileData.size) { @@ -180,7 +180,7 @@ class ImportationFilesManager @Inject constructor(@ApplicationContext private va } private fun copyFileLocally(uri: Uri, fileName: String): File? { - val file = File(getGetLocalCopyFolderOrCopy(), fileName).apply { + val file = File(getImportFolderOrCreate(), fileName).apply { if (exists()) delete() runCatching { createNewFile() }.onFailure { return null }