Fix log path [nocache]

This commit is contained in:
Ali 2020-08-27 13:31:38 +01:00
parent 732f0e6bea
commit 1ef233719c
2 changed files with 9 additions and 1 deletions

View File

@ -414,7 +414,12 @@ func contextMenuForChatPresentationIntefaceState(chatPresentationInterfaceState:
let logsPath = callLogsPath(account: context.account) let logsPath = callLogsPath(account: context.account)
let logPath = logsPath + "/" + logName let logPath = logsPath + "/" + logName
let start = logName.index(logName.startIndex, offsetBy: "\(id)".count + 1) let start = logName.index(logName.startIndex, offsetBy: "\(id)".count + 1)
let end = logName.index(logName.endIndex, offsetBy: -4 - 5) let end: String.Index
if logName.hasSuffix(".log.json") {
end = logName.index(logName.endIndex, offsetBy: -4 - 5)
} else {
end = logName.index(logName.endIndex, offsetBy: -4)
}
let accessHash = logName[start..<end] let accessHash = logName[start..<end]
if let accessHash = Int64(accessHash) { if let accessHash = Int64(accessHash) {
callId = CallId(id: id, accessHash: accessHash) callId = CallId(id: id, accessHash: accessHash)

View File

@ -42,6 +42,9 @@ public func callLogNameForId(id: Int64, account: Account) -> String? {
for url in enumerator { for url in enumerator {
if let url = url as? URL { if let url = url as? URL {
if url.lastPathComponent.hasPrefix(namePrefix) { if url.lastPathComponent.hasPrefix(namePrefix) {
if url.lastPathComponent.hasSuffix(".log.json") {
continue
}
return url.lastPathComponent return url.lastPathComponent
} }
} }