Create folder for new caps
This commit is contained in:
parent
281ae66387
commit
6d18c58f38
@ -170,10 +170,15 @@ final class CapServer {
|
|||||||
throw CapError.unknownId
|
throw CapError.unknownId
|
||||||
}
|
}
|
||||||
var id = 0
|
var id = 0
|
||||||
|
let capFolder = folder(of: cap)
|
||||||
var f = file(of: cap, version: id)
|
var f = file(of: cap, version: id)
|
||||||
while fm.fileExists(atPath: f.path) {
|
if fm.fileExists(atPath: capFolder.path) {
|
||||||
id += 1
|
while fm.fileExists(atPath: f.path) {
|
||||||
f = file(of: cap, version: id)
|
id += 1
|
||||||
|
f = file(of: cap, version: id)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try fm.createDirectory(at: capFolder, withIntermediateDirectories: true)
|
||||||
}
|
}
|
||||||
try data.write(to: f)
|
try data.write(to: f)
|
||||||
caps[cap]!.count = try count(of: cap)
|
caps[cap]!.count = try count(of: cap)
|
||||||
|
Loading…
Reference in New Issue
Block a user