Merge branch 'multiplatform' into av/multiplatform-merged-master
This commit is contained in:
@@ -21,6 +21,8 @@ actual val dbAbsolutePrefixPath: String = dataDir.absolutePath + File.separator
|
||||
actual val chatDatabaseFileName: String = "files_chat.db"
|
||||
actual val agentDatabaseFileName: String = "files_agent.db"
|
||||
|
||||
actual val databaseExportDir: File = androidAppContext.cacheDir
|
||||
|
||||
@Composable
|
||||
actual fun rememberFileChooserLauncher(getContent: Boolean, onResult: (URI?) -> Unit): FileChooserLauncher {
|
||||
val launcher = rememberLauncherForActivityResult(
|
||||
|
||||
@@ -17,6 +17,12 @@ expect val dbAbsolutePrefixPath: String
|
||||
expect val chatDatabaseFileName: String
|
||||
expect val agentDatabaseFileName: String
|
||||
|
||||
/**
|
||||
* This is used only for temporary storing db archive for export.
|
||||
* Providing [tmpDir] instead crashes the app. Check db export before moving from this path to something else
|
||||
* */
|
||||
expect val databaseExportDir: File
|
||||
|
||||
fun copyFileToFile(from: File, to: URI, finally: () -> Unit) {
|
||||
try {
|
||||
to.outputStream().use { stream ->
|
||||
|
||||
@@ -476,7 +476,7 @@ private suspend fun exportChatArchive(
|
||||
val ts = SimpleDateFormat("yyyy-MM-dd'T'HHmmss", Locale.US).format(Date.from(archiveTime.toJavaInstant()))
|
||||
val archiveName = "simplex-chat.$ts.zip"
|
||||
val archivePath = "${filesDir.absolutePath}${File.separator}$archiveName"
|
||||
val config = ArchiveConfig(archivePath, parentTempDirectory = tmpDir.toString())
|
||||
val config = ArchiveConfig(archivePath, parentTempDirectory = databaseExportDir.toString())
|
||||
m.controller.apiExportArchive(config)
|
||||
deleteOldArchive(m)
|
||||
m.controller.appPrefs.chatArchiveName.set(archiveName)
|
||||
@@ -529,7 +529,7 @@ private fun importArchive(
|
||||
try {
|
||||
m.controller.apiDeleteStorage()
|
||||
try {
|
||||
val config = ArchiveConfig(archivePath, parentTempDirectory = tmpDir.toString())
|
||||
val config = ArchiveConfig(archivePath, parentTempDirectory = databaseExportDir.toString())
|
||||
val archiveErrors = m.controller.apiImportArchive(config)
|
||||
DatabaseUtils.ksDatabasePassword.remove()
|
||||
appFilesCountAndSize.value = directoryFileCountAndSize(appFilesDir.absolutePath)
|
||||
@@ -563,7 +563,7 @@ private fun saveArchiveFromURI(importedArchiveURI: URI): String? {
|
||||
val inputStream = importedArchiveURI.inputStream()
|
||||
val archiveName = getFileName(importedArchiveURI)
|
||||
if (inputStream != null && archiveName != null) {
|
||||
val archivePath = "$tmpDir${File.separator}$archiveName"
|
||||
val archivePath = "$databaseExportDir${File.separator}$archiveName"
|
||||
val destFile = File(archivePath)
|
||||
Files.copy(inputStream, destFile.toPath())
|
||||
archivePath
|
||||
|
||||
@@ -25,6 +25,8 @@ actual val dbAbsolutePrefixPath: String = dataDir.absolutePath + File.separator
|
||||
actual val chatDatabaseFileName: String = "simplex_v1_chat.db"
|
||||
actual val agentDatabaseFileName: String = "simplex_v1_agent.db"
|
||||
|
||||
actual val databaseExportDir: File = tmpDir
|
||||
|
||||
@Composable
|
||||
actual fun rememberFileChooserLauncher(getContent: Boolean, onResult: (URI?) -> Unit): FileChooserLauncher =
|
||||
remember { FileChooserLauncher(getContent, onResult) }
|
||||
|
||||
Reference in New Issue
Block a user