From 5861c381b81577ec20d931a2c753f6fd0a36466a Mon Sep 17 00:00:00 2001 From: Ali <> Date: Fri, 29 Jan 2021 19:13:30 +0500 Subject: [PATCH] Add more logs --- .../Telegram-iOS/en.lproj/Localizable.strings | 2 +- .../Sources/ChatImportActivityScreen.swift | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 58e778a2eb..18c959a242 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -5959,7 +5959,7 @@ Sorry for the inconvenience."; "ChatImportActivity.ErrorInvalidChatType" = "Wrong type of chat for the messages you are trying to import."; "ChatImportActivity.ErrorUserBlocked" = "Unable to import messages due to privacy settings."; "ChatImportActivity.ErrorGeneric" = "An error occurred."; -"ChatImportActivity.ErrorLimitExceeded" = "Limit exceeded. Please try again later."; +"ChatImportActivity.ErrorLimitExceeded" = "Daily maximum reached,\nplease come back tomorrow."; "ChatImportActivity.Success" = "Chat imported\nsuccessfully."; "VoiceOver.Chat.GoToOriginalMessage" = "Go to message"; diff --git a/submodules/ChatImportUI/Sources/ChatImportActivityScreen.swift b/submodules/ChatImportUI/Sources/ChatImportActivityScreen.swift index f7f990190d..0bb0ff9835 100644 --- a/submodules/ChatImportUI/Sources/ChatImportActivityScreen.swift +++ b/submodules/ChatImportUI/Sources/ChatImportActivityScreen.swift @@ -109,6 +109,11 @@ private final class ImportManager { self.stateValue = .progress(totalBytes: self.totalBytes, totalUploadedBytes: 0, totalMediaBytes: self.totalMediaBytes, totalUploadedMediaBytes: 0) + Logger.shared.log("ChatImportScreen", "Requesting import session for \(peerId), media count: \(entries.count) with pending entries:") + for entry in entries { + Logger.shared.log("ChatImportScreen", " \(entry.1)") + } + self.disposable.set((ChatHistoryImport.initSession(account: self.account, peerId: peerId, file: mainFile, mediaCount: Int32(entries.count)) |> mapError { error -> ImportError in switch error { @@ -191,28 +196,37 @@ private final class ImportManager { private func updateState() { guard let session = self.session else { + Logger.shared.log("ChatImportScreen", "updateState called with no session, ignoring") return } if self.pendingEntries.isEmpty && self.activeEntries.isEmpty { + Logger.shared.log("ChatImportScreen", "updateState called with no pending and no active entries, completing") self.complete() return } if case .error = self.stateValue { + Logger.shared.log("ChatImportScreen", "updateState called after error, ignoring") return } guard let archivePath = self.archivePath else { + Logger.shared.log("ChatImportScreen", "updateState called with empty arhivePath, ignoring") return } while true { if self.activeEntries.count >= 3 { + Logger.shared.log("ChatImportScreen", "updateState concurrent processing limit reached, stop searching") break } if self.pendingEntries.isEmpty { + Logger.shared.log("ChatImportScreen", "updateState no more pending entries, stop searching") break } let entry = self.pendingEntries.removeFirst() + + Logger.shared.log("ChatImportScreen", "updateState take pending entry \(entry.1)") + let unpackedFile = Signal { subscriber in let tempFile = TempBox.shared.tempFile(fileName: entry.0.path) Logger.shared.log("ChatImportScreen", "Extracting \(entry.0.path) to \(tempFile.path)...") @@ -269,6 +283,7 @@ private final class ImportManager { guard let strongSelf = self else { return } + Logger.shared.log("ChatImportScreen", "updateState entry \(entry.1) has completed upload") strongSelf.activeEntries.removeValue(forKey: entry.0.path) strongSelf.updateState() }))