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