allow querying file size on SQLiteStore

This commit is contained in:
John Rommel Estropia
2017-07-01 11:50:23 +09:00
parent 8d926d25ec
commit 809aa4ff96
2 changed files with 16 additions and 1 deletions

View File

@@ -117,6 +117,20 @@ public final class SQLiteStore: LocalStorage {
)
}
/**
Queries the file size (in bytes) of the store, or `nil` if the file does not exist yet
*/
public func fileSize() -> UInt64? {
guard let attribute = try? FileManager.default.attributesOfItem(atPath: self.fileURL.path),
let sizeAttribute = attribute[.size],
let fileSize = sizeAttribute as? NSNumber else {
return nil
}
return fileSize.uint64Value
}
// MARK: StorageInterface