diff --git a/internal/httpapi/library_flow.go b/internal/httpapi/library_flow.go index b3e1d16..c2aa4fb 100644 --- a/internal/httpapi/library_flow.go +++ b/internal/httpapi/library_flow.go @@ -2,6 +2,8 @@ package httpapi import ( "context" + "crypto/sha256" + "encoding/hex" "encoding/json" "errors" "fmt" @@ -376,8 +378,11 @@ func libraryMaintenanceRecoverHandler(w http.ResponseWriter, r *http.Request, co return } // 队列作业 id 与幂等键都按窗口固定:重复点击只会得到同一个恢复作业。 + // 队列 id 有长度上限(36),窗口作业 id 比它还长,所以按窗口摘要取短 id。 + sum := sha256.Sum256([]byte(held.OwnerJobID)) + queueID := "lrec-" + hex.EncodeToString(sum[:14]) queueJob, err := config.Store.Enqueue(r.Context(), jobs.EnqueueRequest{ - ID: "librecover-" + held.OwnerJobID, Type: libraryRecoverJobType, Payload: payload, + ID: queueID, Type: libraryRecoverJobType, Payload: payload, AvailableAt: now, MaxAttempts: 1, IdempotencyKey: "library.recover:" + held.OwnerJobID, }, now) if err != nil || queueJob == nil {