core: fix archive export when some filename is not compatible with zip (#4561)

* core: fix archive export when some filename is not compatible with zip

* update

* core, ios

* update kotlin apis, ios: add alert to migrate from device
This commit is contained in:
Evgeny Poberezkin
2024-08-02 20:23:54 +01:00
committed by GitHub
parent 8fbba16f53
commit cb76c8079c
10 changed files with 115 additions and 38 deletions
@@ -782,9 +782,9 @@ object ChatController {
throw Exception("failed to get app settings: ${r.responseType} ${r.details}")
}
suspend fun apiExportArchive(config: ArchiveConfig) {
suspend fun apiExportArchive(config: ArchiveConfig): List<ArchiveError> {
val r = sendCmd(null, CC.ApiExportArchive(config))
if (r is CR.CmdOk) return
if (r is CR.ArchiveExported) return r.archiveErrors
throw Exception("failed to export archive: ${r.responseType} ${r.details}")
}
@@ -4882,6 +4882,7 @@ sealed class CR {
@Serializable @SerialName("cmdOk") class CmdOk(val user: UserRef?): CR()
@Serializable @SerialName("chatCmdError") class ChatCmdError(val user_: UserRef?, val chatError: ChatError): CR()
@Serializable @SerialName("chatError") class ChatRespError(val user_: UserRef?, val chatError: ChatError): CR()
@Serializable @SerialName("archiveExported") class ArchiveExported(val archiveErrors: List<ArchiveError>): CR()
@Serializable @SerialName("archiveImported") class ArchiveImported(val archiveErrors: List<ArchiveError>): CR()
@Serializable @SerialName("appSettings") class AppSettingsR(val appSettings: AppSettings): CR()
@Serializable @SerialName("agentSubsTotal") class AgentSubsTotal(val user: UserRef, val subsTotal: SMPServerSubs, val hasSession: Boolean): CR()
@@ -5051,6 +5052,7 @@ sealed class CR {
is CmdOk -> "cmdOk"
is ChatCmdError -> "chatCmdError"
is ChatRespError -> "chatError"
is ArchiveExported -> "archiveExported"
is ArchiveImported -> "archiveImported"
is AppSettingsR -> "appSettings"
is Response -> "* $type"
@@ -5235,6 +5237,7 @@ sealed class CR {
is CmdOk -> withUser(user, noDetails())
is ChatCmdError -> withUser(user_, chatError.string)
is ChatRespError -> withUser(user_, chatError.string)
is ArchiveExported -> "${archiveErrors.map { it.string } }"
is ArchiveImported -> "${archiveErrors.map { it.string } }"
is AppSettingsR -> json.encodeToString(appSettings)
is Response -> json
@@ -6040,11 +6043,11 @@ sealed class RCErrorType {
@Serializable
sealed class ArchiveError {
val string: String get() = when (this) {
is ArchiveErrorImport -> "import ${chatError.string}"
is ArchiveErrorImportFile -> "importFile $file ${chatError.string}"
is ArchiveErrorImport -> "import ${importError}"
is ArchiveErrorFile -> "importFile $file ${fileError}"
}
@Serializable @SerialName("import") class ArchiveErrorImport(val chatError: ChatError): ArchiveError()
@Serializable @SerialName("importFile") class ArchiveErrorImportFile(val file: String, val chatError: ChatError): ArchiveError()
@Serializable @SerialName("import") class ArchiveErrorImport(val importError: String): ArchiveError()
@Serializable @SerialName("fileError") class ArchiveErrorFile(val file: String, val fileError: String): ArchiveError()
}
@Serializable