Protect thumbnail upload, remove unused function
This commit is contained in:
parent
267a71d78c
commit
f956b8b4d2
@ -247,19 +247,6 @@ final class CapServer: ServerOwner {
|
||||
|
||||
// MARK: Counts
|
||||
|
||||
private func updateCounts() throws {
|
||||
do {
|
||||
caps = try caps.mapValues {
|
||||
var cap = $0
|
||||
cap.count = try count(of: $0.id)
|
||||
return cap
|
||||
}
|
||||
} catch {
|
||||
log("Failed to update counts: \(error)")
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
private func images(in folder: URL) throws -> [URL] {
|
||||
try fm.contentsOfDirectory(at: folder, includingPropertiesForKeys: nil)
|
||||
.filter { $0.pathExtension == "jpg" }
|
||||
|
@ -84,11 +84,13 @@ func routes(_ app: Application) {
|
||||
return missingThumbnails.map(String.init).joined(separator: ",")
|
||||
}
|
||||
|
||||
// Upload the thumbnail of a cap
|
||||
app.postCatching("thumbnails", ":cap") { request in
|
||||
guard let cap = request.parameters.get("cap", as: Int.self) else {
|
||||
log("Invalid cap parameter for thumbnail upload")
|
||||
throw Abort(.badRequest)
|
||||
}
|
||||
try authorize(request)
|
||||
let data = try request.getBodyData()
|
||||
server.saveThumbnail(data, for: cap)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user