Единое окно: полное пользовательское удаление загрузки (delete)
Вторая половина «единого окна»: команда «Удалить» снимает наши библиотечные хардлинки (гард последней копии осознанно выключен, в отличие от Undo) и сносит раздачу с файлами из qBittorrent (deleteFiles=true) → терминальный deleted. Доступна из done/orphaned/target_missing, идемпотентна к отсутствующей стороне; инициатор различается через error_code=user_delete. Подтверждение обязательно: веб — danger-секция внизу страницы (hx-confirm + details), Telegram — двухшаговый inline-confirm. qbt.Delete + layout.Remove (unlink без ErrLastCopy, только свои ссылки под movies/series). Граф переходов не менялся — рёбра уже были. OpenSpec: state-reconciliation +1 требование; синк workflow.md; беклог закрыт. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,7 @@ func (s stubCommander) Retry(context.Context, string) error { return s.retryErr
|
||||
type actionReviewer struct {
|
||||
stubReviewer
|
||||
undoErr error
|
||||
deleteErr error
|
||||
relinkErr error
|
||||
rerecognizeErr error
|
||||
refineErr error
|
||||
@@ -32,6 +33,7 @@ type actionReviewer struct {
|
||||
}
|
||||
|
||||
func (a actionReviewer) Undo(context.Context, string) error { return a.undoErr }
|
||||
func (a actionReviewer) Delete(context.Context, string) error { return a.deleteErr }
|
||||
func (a actionReviewer) Relink(context.Context, string) error { return a.relinkErr }
|
||||
func (a actionReviewer) Rerecognize(context.Context, string) error { return a.rerecognizeErr }
|
||||
func (a actionReviewer) Refine(_ context.Context, _ string, hint string) error {
|
||||
|
||||
@@ -53,6 +53,7 @@ type downloadDetailView struct {
|
||||
Undoable bool
|
||||
Relinkable bool
|
||||
Retriable bool
|
||||
Deletable bool // полное удаление доступно (done/orphaned/target_missing)
|
||||
}
|
||||
|
||||
// detailTitle — заголовок страницы просмотра: имя раздачи (display_name) →
|
||||
@@ -111,6 +112,8 @@ func (s *server) buildDownloadView(id string, rd *worker.ReviewData) downloadDet
|
||||
Relinkable: d.State == store.StateReverted || d.State == store.StateCancelled ||
|
||||
d.State == store.StateTargetMissing,
|
||||
Retriable: d.State == store.StateFailed || d.State == store.StateStuck,
|
||||
Deletable: d.State == store.StateDone || d.State == store.StateOrphaned ||
|
||||
d.State == store.StateTargetMissing,
|
||||
}
|
||||
// Дата добавления рядом с шапкой (source_added_at → фолбэк created_at,
|
||||
// как в порядке и карточках списка); неразбираемое время просто опускаем.
|
||||
|
||||
@@ -137,6 +137,7 @@ func NewRouter(d Deps) (http.Handler, error) {
|
||||
r.Post("/ui/downloads/{id}/defer", s.handleDefer)
|
||||
r.Post("/ui/downloads/{id}/undo", s.handleUndo)
|
||||
r.Post("/ui/downloads/{id}/relink", s.handleRelink)
|
||||
r.Post("/ui/downloads/{id}/delete", s.handleDelete)
|
||||
|
||||
// REST API.
|
||||
r.Route("/api", func(r chi.Router) {
|
||||
|
||||
@@ -454,6 +454,7 @@ type fakeReviewer struct {
|
||||
applied []string
|
||||
deferred []string
|
||||
undone []string
|
||||
deleted []string
|
||||
relinked []string
|
||||
rerecognized []string
|
||||
cleared []string
|
||||
@@ -491,6 +492,10 @@ func (f *fakeReviewer) Undo(_ context.Context, id string) error {
|
||||
f.undone = append(f.undone, id)
|
||||
return nil
|
||||
}
|
||||
func (f *fakeReviewer) Delete(_ context.Context, id string) error {
|
||||
f.deleted = append(f.deleted, id)
|
||||
return nil
|
||||
}
|
||||
func (f *fakeReviewer) Relink(_ context.Context, id string) error {
|
||||
f.relinked = append(f.relinked, id)
|
||||
return nil
|
||||
|
||||
@@ -49,6 +49,7 @@ func (stubReviewer) SetType(context.Context, string, string) error
|
||||
func (stubReviewer) IgnoreFile(context.Context, string, string) error { return nil }
|
||||
func (stubReviewer) Defer(context.Context, string) error { return nil }
|
||||
func (stubReviewer) Undo(context.Context, string) error { return nil }
|
||||
func (stubReviewer) Delete(context.Context, string) error { return nil }
|
||||
func (stubReviewer) Relink(context.Context, string) error { return nil }
|
||||
func (stubReviewer) Rerecognize(context.Context, string) error { return nil }
|
||||
func (stubReviewer) ChooseCandidate(context.Context, string, string) error { return nil }
|
||||
|
||||
@@ -21,6 +21,7 @@ type Reviewer interface {
|
||||
IgnoreFile(ctx context.Context, id string, src string) error
|
||||
Defer(ctx context.Context, id string) error
|
||||
Undo(ctx context.Context, id string) error
|
||||
Delete(ctx context.Context, id string) error
|
||||
Relink(ctx context.Context, id string) error
|
||||
Rerecognize(ctx context.Context, id string) error
|
||||
ChooseCandidate(ctx context.Context, id, candidateID string) error
|
||||
@@ -332,6 +333,19 @@ func (s *server) handleUndo(w http.ResponseWriter, r *http.Request) {
|
||||
s.surfaceAction(w, r, id, s.deps.Reviewer.Undo(r.Context(), id))
|
||||
}
|
||||
|
||||
// handleDelete — полное удаление загрузки (снять хардлинки + снести раздачу с
|
||||
// файлами из qBittorrent → deleted). Осознанное необратимое действие: транспорт
|
||||
// подтверждает его перед POST (hx-confirm + отдельная danger-секция). Ошибку
|
||||
// qBittorrent surfaceAction покажет как отказ (не тихий успех).
|
||||
func (s *server) handleDelete(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := pathID(r)
|
||||
if err != nil {
|
||||
redirectErr(w, r, "некорректный id")
|
||||
return
|
||||
}
|
||||
s.surfaceAction(w, r, id, s.deps.Reviewer.Delete(r.Context(), id))
|
||||
}
|
||||
|
||||
// handleRelink повторно привязывает откатанную задачу: перезапускает
|
||||
// распознавание, задача пройдёт recognizing → review для подтверждения.
|
||||
func (s *server) handleRelink(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user