mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add a Log Files entry to the Usage sizes. (#4921)
This commit is contained in:
@@ -59,6 +59,19 @@ extension FileManager {
|
|||||||
|
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sizeForDirectory(at url: URL) throws -> UInt {
|
||||||
|
guard let enumerator = enumerator(at: url, includingPropertiesForKeys: [.fileSizeKey, .isDirectoryKey]) else {
|
||||||
|
throw FileManagerError.invalidFileSize
|
||||||
|
}
|
||||||
|
|
||||||
|
return try enumerator
|
||||||
|
.compactMap {
|
||||||
|
guard let fileURL = $0 as? URL else { return nil }
|
||||||
|
return try UInt(fileURL.resourceValues(forKeys: [.fileSizeKey]).fileSize ?? 0)
|
||||||
|
}
|
||||||
|
.reduce(0, +)
|
||||||
|
}
|
||||||
|
|
||||||
func numberOfItems(at url: URL) throws -> Int {
|
func numberOfItems(at url: URL) throws -> Int {
|
||||||
try contentsOfDirectory(at: url, includingPropertiesForKeys: nil).count
|
try contentsOfDirectory(at: url, includingPropertiesForKeys: nil).count
|
||||||
|
|||||||
+3
@@ -40,6 +40,9 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
|
|||||||
if let mediaStore = sizes.mediaStore {
|
if let mediaStore = sizes.mediaStore {
|
||||||
components.append(.init(name: "MediaStore", size: formatter.format(Int64(mediaStore))))
|
components.append(.init(name: "MediaStore", size: formatter.format(Int64(mediaStore))))
|
||||||
}
|
}
|
||||||
|
if let logsSize = try? FileManager.default.sizeForDirectory(at: .appGroupLogsDirectory) {
|
||||||
|
components.append(.init(name: "Log Files", size: formatter.format(Int64(logsSize))))
|
||||||
|
}
|
||||||
|
|
||||||
state.storeSizes = components
|
state.storeSizes = components
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user