check / check (push) Waiting to run
Replaces #559, which conflicted. Model: opus-5-5
32 lines
822 B
Go
32 lines
822 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"sneak.berlin/go/webhooker/internal/database"
|
|
)
|
|
|
|
// HandleTargetDelete handles deleting a target. A deleted
|
|
// database target's archive writer is evicted and its handle
|
|
// closed; the archive file is left on disk.
|
|
func (h *Handlers) HandleTargetDelete() http.HandlerFunc {
|
|
return h.deleteChildResource(
|
|
"targetID", &database.Target{},
|
|
"failed to delete target",
|
|
h.evictTargetArchiveWriter,
|
|
targetDeleted,
|
|
)
|
|
}
|
|
|
|
// evictTargetArchiveWriter is evictArchiveWriter for one deleted
|
|
// target, and leaves its archive file on disk for the same reason.
|
|
// A target that is not a database target has no writer, and
|
|
// evicting it does nothing.
|
|
func (h *Handlers) evictTargetArchiveWriter(targetID string) {
|
|
if h.archives == nil {
|
|
return
|
|
}
|
|
|
|
h.archives.EvictTarget(targetID)
|
|
}
|