mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-20 00:24:26 +01:00
allow querying file size on SQLiteStore
This commit is contained in:
@@ -868,7 +868,8 @@ extension SQLiteStore: CustomDebugStringConvertible, CoreStoreDebugStringConvert
|
|||||||
("storeOptions", self.storeOptions as Any),
|
("storeOptions", self.storeOptions as Any),
|
||||||
("fileURL", self.fileURL),
|
("fileURL", self.fileURL),
|
||||||
("migrationMappingProviders", self.migrationMappingProviders),
|
("migrationMappingProviders", self.migrationMappingProviders),
|
||||||
("localStorageOptions", self.localStorageOptions)
|
("localStorageOptions", self.localStorageOptions),
|
||||||
|
("fileSize", self.fileSize() as Any)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
// MARK: StorageInterface
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user