Fix chat import with non-normalized file names

This commit is contained in:
Ali 2021-03-11 17:11:10 +04:00
parent b7eb646bb3
commit dce1cc7776
2 changed files with 9 additions and 8 deletions

View File

@ -101,7 +101,7 @@ private final class ImportManager {
var totalMediaBytes = 0 var totalMediaBytes = 0
for entry in self.entries { for entry in self.entries {
self.entryProgress[entry.0.path] = (Int(entry.0.uncompressedSize), 0) self.entryProgress[entry.1] = (Int(entry.0.uncompressedSize), 0)
totalMediaBytes += Int(entry.0.uncompressedSize) totalMediaBytes += Int(entry.0.uncompressedSize)
} }
self.totalBytes = self.mainFileSize + totalMediaBytes self.totalBytes = self.mainFileSize + totalMediaBytes
@ -277,8 +277,8 @@ private final class ImportManager {
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }
if let (size, _) = strongSelf.entryProgress[entry.0.path] { if let (size, _) = strongSelf.entryProgress[entry.1] {
strongSelf.entryProgress[entry.0.path] = (size, Int(progress * Float(entry.0.uncompressedSize))) strongSelf.entryProgress[entry.1] = (size, Int(progress * Float(entry.0.uncompressedSize)))
strongSelf.updateProgress() strongSelf.updateProgress()
} }
}, error: { [weak self] error in }, error: { [weak self] error in
@ -290,8 +290,9 @@ private final class ImportManager {
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }
Logger.shared.log("ChatImportScreen", "updateState entry \(entry.1) has completed upload") Logger.shared.log("ChatImportScreen", "updateState entry \(entry.1) has completed upload, previous active entries: \(strongSelf.activeEntries.keys)")
strongSelf.activeEntries.removeValue(forKey: entry.0.path) strongSelf.activeEntries.removeValue(forKey: entry.1)
Logger.shared.log("ChatImportScreen", "removed active entry \(entry.1), current active entries: \(strongSelf.activeEntries.keys)")
strongSelf.updateState() strongSelf.updateState()
})) }))
} }

View File

@ -764,7 +764,7 @@ struct OrderedHistoryViewEntries {
if self.lowerOrAtAnchor.count > 1 { if self.lowerOrAtAnchor.count > 1 {
for i in 1 ..< self.lowerOrAtAnchor.count { for i in 1 ..< self.lowerOrAtAnchor.count {
if self.lowerOrAtAnchor[i].index < self.lowerOrAtAnchor[i - 1].index { if self.lowerOrAtAnchor[i].index < self.lowerOrAtAnchor[i - 1].index {
assertionFailure() //assertionFailure()
break break
} }
} }
@ -772,7 +772,7 @@ struct OrderedHistoryViewEntries {
if self.higherThanAnchor.count > 1 { if self.higherThanAnchor.count > 1 {
for i in 1 ..< self.higherThanAnchor.count { for i in 1 ..< self.higherThanAnchor.count {
if self.higherThanAnchor[i].index < self.higherThanAnchor[i - 1].index { if self.higherThanAnchor[i].index < self.higherThanAnchor[i - 1].index {
assertionFailure() //assertionFailure()
break break
} }
} }
@ -796,7 +796,7 @@ struct OrderedHistoryViewEntries {
} }
} }
if fix { if fix {
assertionFailure() //assertionFailure()
self.lowerOrAtAnchor.sort(by: { $0.index.id.id < $1.index.id.id }) self.lowerOrAtAnchor.sort(by: { $0.index.id.id < $1.index.id.id })
self.higherThanAnchor.sort(by: { $0.index.id.id < $1.index.id.id }) self.higherThanAnchor.sort(by: { $0.index.id.id < $1.index.id.id })
} }