1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-03-30 08:20:09 +02:00

👌 Avoid force unwrapping try (may crash)

This commit is contained in:
2023-03-23 19:08:39 +01:00
parent 966033e052
commit d320c49092

View File

@@ -14,14 +14,18 @@ class ValetDomainScanner: DomainScanner {
func resolveSiteCount(paths: [String]) -> Int { func resolveSiteCount(paths: [String]) -> Int {
return paths.map { path in return paths.map { path in
do {
let entries = try! FileSystem let entries = try FileSystem
.getShallowContentsOfDirectory(path) .getShallowContentsOfDirectory(path)
return entries return entries
.map { self.isSite($0, forPath: path) } .map { self.isSite($0, forPath: path) }
.filter { $0 == true} .filter { $0 == true}
.count .count
} catch {
Log.err("Unexpected error getting contents of \(path): \(error).")
return 0
}
}.reduce(0, +) }.reduce(0, +)
} }