From b63b9e152c014a53ab0bc8c7dac0a5f603d6d567 Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Fri, 10 Feb 2017 00:50:03 +0800 Subject: [PATCH] show size in about repository --- .../Controllers/AboutRepositoryTableViewController.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pass/Controllers/AboutRepositoryTableViewController.swift b/pass/Controllers/AboutRepositoryTableViewController.swift index da01bff..1221e85 100644 --- a/pass/Controllers/AboutRepositoryTableViewController.swift +++ b/pass/Controllers/AboutRepositoryTableViewController.swift @@ -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()], ], ]