Compare commits
No commits in common. "e7a54ec8ec2e1440de37624f0a2ec0529c6e9bbe" and "6e5cc06d31ac7a401d7685a38f13cb311e21535b" have entirely different histories.
e7a54ec8ec
...
6e5cc06d31
@ -120,19 +120,6 @@ extension CapServer {
|
|||||||
}
|
}
|
||||||
return try encoder.encode(cap)
|
return try encoder.encode(cap)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete a cap completely, with all images
|
|
||||||
app.postCatching("delete", ":cap") { request in
|
|
||||||
guard let cap = request.parameters.get("cap", as: Int.self) else {
|
|
||||||
log("/delete/:cap/: Invalid 'cap' parameter for image deletion")
|
|
||||||
throw Abort(.badRequest)
|
|
||||||
}
|
|
||||||
try self.ensureOperability()
|
|
||||||
try authenticator.authorize(request)
|
|
||||||
guard self.delete(cap: cap) else {
|
|
||||||
throw Abort(.gone)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,10 +358,9 @@ final class CapServer {
|
|||||||
log("Failed to write image \(id) for cap \(cap): \(error)")
|
log("Failed to write image \(id) for cap \(cap): \(error)")
|
||||||
throw CapError.invalidFile
|
throw CapError.invalidFile
|
||||||
}
|
}
|
||||||
let count = try count(of: cap)
|
caps[cap]!.count = try count(of: cap)
|
||||||
caps[cap]!.count = count
|
|
||||||
addChangedImageToLog(cap: cap, image: id)
|
addChangedImageToLog(cap: cap, image: id)
|
||||||
log("Added image \(id) for cap \(cap) (\(count) total)")
|
log("Added image \(id) for cap \(cap)")
|
||||||
}
|
}
|
||||||
|
|
||||||
private func writeChangedImagesToDisk() throws {
|
private func writeChangedImagesToDisk() throws {
|
||||||
@ -506,39 +505,6 @@ final class CapServer {
|
|||||||
return caps[capId]!
|
return caps[capId]!
|
||||||
}
|
}
|
||||||
|
|
||||||
func delete(cap capId: Int) -> Bool {
|
|
||||||
guard caps[capId] != nil else {
|
|
||||||
log("Attempting to delete unknown cap \(capId)")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
// 1. Remove all images
|
|
||||||
do {
|
|
||||||
let imageFolderUrl = folder(of: capId)
|
|
||||||
if exists(imageFolderUrl) {
|
|
||||||
try fm.removeItem(at: imageFolderUrl)
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
log("Failed to delete image folder of cap \(capId): \(error)")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
// 2. Remove thumbnail
|
|
||||||
do {
|
|
||||||
let url = thumbnail(of: capId)
|
|
||||||
if exists(url) {
|
|
||||||
try fm.removeItem(at: url)
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
log("Failed to delete thumbnail of cap \(capId): \(error)")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Remove cap
|
|
||||||
caps[capId] = nil
|
|
||||||
saveCapCountHTML()
|
|
||||||
updateGridCapCount()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: Classifier
|
// MARK: Classifier
|
||||||
|
|
||||||
func updateTrainedClasses(content: String) {
|
func updateTrainedClasses(content: String) {
|
||||||
|
Loading…
Reference in New Issue
Block a user