mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-09 12:43:01 +02:00
🐛 Fix unsafe usage of try for path handling
This commit is contained in:
@@ -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
|
||||||
|
.getShallowContentsOfDirectory(path)
|
||||||
|
|
||||||
let entries = try! FileSystem
|
return entries
|
||||||
.getShallowContentsOfDirectory(path)
|
.map { self.isSite($0, forPath: path) }
|
||||||
|
.filter { $0 == true}
|
||||||
return entries
|
.count
|
||||||
.map { self.isSite($0, forPath: path) }
|
} catch {
|
||||||
.filter { $0 == true}
|
Log.err("Unexpected error getting contents of \(path): \(error).")
|
||||||
.count
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
}.reduce(0, +)
|
}.reduce(0, +)
|
||||||
}
|
}
|
||||||
@@ -30,13 +34,17 @@ class ValetDomainScanner: DomainScanner {
|
|||||||
var sites: [ValetSite] = []
|
var sites: [ValetSite] = []
|
||||||
|
|
||||||
paths.forEach { path in
|
paths.forEach { path in
|
||||||
let entries = try! FileSystem
|
do {
|
||||||
.getShallowContentsOfDirectory(path)
|
let entries = try FileSystem
|
||||||
|
.getShallowContentsOfDirectory(path)
|
||||||
|
|
||||||
return entries.forEach {
|
return entries.forEach {
|
||||||
if let site = self.resolveSite(path: "\(path)/\($0)") {
|
if let site = self.resolveSite(path: "\(path)/\($0)") {
|
||||||
sites.append(site)
|
sites.append(site)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
Log.err("Unexpected error getting contents of \(path): \(error).")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user