Add more logs

This commit is contained in:
Ali 2021-04-01 18:00:54 +04:00
parent c9cf1ae1d1
commit 2ad13066c5
2 changed files with 17 additions and 4 deletions

View File

@ -124,7 +124,7 @@ final class AccountManagerImpl {
self.tables.append(self.sharedDataTable)
self.tables.append(self.noticeTable)
print("AccountManager initialization took \((CFAbsoluteTimeGetCurrent() - startTime) * 1000.0) ms")
postboxLog("AccountManager initialization took \((CFAbsoluteTimeGetCurrent() - startTime) * 1000.0) ms")
}
deinit {

View File

@ -1129,6 +1129,8 @@ public func openPostbox(basePath: String, seedConfiguration: SeedConfiguration,
let queue = sharedQueue
return Signal { subscriber in
queue.async {
postboxLog("openPostbox, basePath: \(basePath), useCopy: \(useCopy)")
let _ = try? FileManager.default.createDirectory(atPath: basePath, withIntermediateDirectories: true, attributes: nil)
var tempDir: TempBoxDirectory?
@ -1149,6 +1151,7 @@ public func openPostbox(basePath: String, seedConfiguration: SeedConfiguration,
return
}
} else {
postboxLog("openPostbox, error1")
subscriber.putNext(.error)
return
}
@ -1163,10 +1166,14 @@ public func openPostbox(basePath: String, seedConfiguration: SeedConfiguration,
#endif
let startTime = CFAbsoluteTimeGetCurrent()
postboxLog("openPostbox, initialize SqliteValueBox")
guard var valueBox = SqliteValueBox(basePath: dbBasePath, queue: queue, isTemporary: isTemporary, isReadOnly: isReadOnly, encryptionParameters: encryptionParameters, upgradeProgress: { progress in
postboxLog("openPostbox, SqliteValueBox upgrading progress \(progress)")
subscriber.putNext(.upgrading(progress))
}) else {
postboxLog("openPostbox, SqliteValueBox open error")
subscriber.putNext(.error)
return
}
@ -1176,10 +1183,13 @@ public func openPostbox(basePath: String, seedConfiguration: SeedConfiguration,
let userVersion: Int32? = metadataTable.userVersion()
let currentUserVersion: Int32 = 25
postboxLog("openPostbox, current userVersion: \(userVersion ?? nil)")
if let userVersion = userVersion {
if userVersion != currentUserVersion {
if isTemporary {
postboxLog("openPostbox, isTemporary = true, not upgrading")
subscriber.putNext(.error)
return
} else {
@ -1241,9 +1251,12 @@ public func openPostbox(basePath: String, seedConfiguration: SeedConfiguration,
}
let endTime = CFAbsoluteTimeGetCurrent()
print("Postbox load took \((endTime - startTime) * 1000.0) ms")
postboxLog("Postbox load took \((endTime - startTime) * 1000.0) ms")
subscriber.putNext(.postbox(Postbox(queue: queue, basePath: basePath, seedConfiguration: seedConfiguration, valueBox: valueBox, timestampForAbsoluteTimeBasedOperations: timestampForAbsoluteTimeBasedOperations, isTemporary: isTemporary, tempDir: tempDir)))
postboxLog("openPostbox, putCompletion")
subscriber.putCompletion()
break
}
@ -1407,7 +1420,7 @@ public final class Postbox {
self.seedConfiguration = seedConfiguration
self.tempDir = tempDir
print("MediaBox path: \(self.basePath + "/media")")
postboxLog("MediaBox path: \(self.basePath + "/media")")
self.mediaBox = MediaBox(basePath: self.basePath + "/media")
self.valueBox = valueBox
@ -1546,7 +1559,7 @@ public final class Postbox {
})
)
print("(Postbox initialization took \((CFAbsoluteTimeGetCurrent() - startTime) * 1000.0) ms")
postboxLog("(Postbox initialization took \((CFAbsoluteTimeGetCurrent() - startTime) * 1000.0) ms")
let _ = self.transaction({ transaction -> Void in
let reindexUnreadVersion: Int32 = 2