show size in about repository

This commit is contained in:
Bob Sun 2017-02-10 00:50:03 +08:00
parent c00f13cd42
commit b63b9e152c
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4

View file

@ -14,9 +14,18 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
navigationItemTitle = "About Repository"
super.viewDidLoad()
let passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData()
let fm = FileManager.default
var size = UInt64(0)
do {
size = try fm.allocatedSizeOfDirectoryAtURL(directoryURL: PasswordStore.shared.storeURL)
} catch {
print(error)
}
let formatted = ByteCountFormatter.string(fromByteCount: Int64(size), countStyle: ByteCountFormatter.CountStyle.file)
tableData = [
// section 0
[[.type: CellDataType.detail, .title: "Passwords", .detailText: String(passwordEntities.count)],
[.type: CellDataType.detail, .title: "Size", .detailText: formatted],
[.type: CellDataType.detail, .title: "Last Updated", .detailText: Utils.getLastUpdatedTimeString()],
],
]