Create cap folder only when missing
This commit is contained in:
parent
9abe7d7918
commit
3ce2f4b226
@ -46,7 +46,7 @@ private func countImages(in folder: URL) throws -> Int {
|
||||
private func count(of cap: Int) throws -> Int {
|
||||
let f = folder(of: cap)
|
||||
guard fm.fileExists(atPath: f.path) else {
|
||||
throw CapError.unknownId
|
||||
return 0
|
||||
}
|
||||
return try countImages(in: f)
|
||||
}
|
||||
@ -84,7 +84,9 @@ public func routes(_ router: Router) throws {
|
||||
caps.append(name)
|
||||
// Create image folder
|
||||
let url = folder(of: cap)
|
||||
if !fm.fileExists(atPath: url.path) {
|
||||
try fm.createDirectory(at: url, withIntermediateDirectories: false)
|
||||
}
|
||||
} else {
|
||||
caps[cap] = name
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user