mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-03 15:06:36 +08:00
fix(pages): 收紧部署包与 Agent 同步边界
完成 V2 Phase 0 安全与一致性前置:统一真实归档限额、流式拉取、候选裁剪、保留上传删除语义及 Pages 路由引用锁。
This commit is contained in:
@@ -62,15 +62,22 @@ func GetActiveUploadByID(ctx context.Context, id uint64) (model.Upload, error) {
|
||||
return upload, nil
|
||||
}
|
||||
|
||||
// SoftDeleteUpload marks an upload as deleted.
|
||||
// SoftDeleteUpload marks an active upload as deleted and reports whether the row transitioned.
|
||||
// External modules must use upload.Remove or upload.RemoveOwned; only internal/apps/upload may call this.
|
||||
func SoftDeleteUpload(ctx context.Context, upload *model.Upload) error {
|
||||
func SoftDeleteUpload(ctx context.Context, upload *model.Upload) (int64, error) {
|
||||
return SoftDeleteUploadTx(db.DB(ctx), upload)
|
||||
}
|
||||
|
||||
// SoftDeleteUploadTx marks an upload as deleted within an existing transaction.
|
||||
func SoftDeleteUploadTx(tx *gorm.DB, upload *model.Upload) error {
|
||||
return tx.Model(upload).Update("status", model.UploadStatusDeleted).Error
|
||||
// SoftDeleteUploadTx marks an active upload as deleted within an existing transaction.
|
||||
// RowsAffected is one only for the single successful active-to-deleted transition.
|
||||
func SoftDeleteUploadTx(tx *gorm.DB, upload *model.Upload) (int64, error) {
|
||||
result := tx.Model(&model.Upload{}).
|
||||
Where("id = ? AND status IN ?", upload.ID, []model.UploadStatus{
|
||||
model.UploadStatusPending,
|
||||
model.UploadStatusUsed,
|
||||
}).
|
||||
Update("status", model.UploadStatusDeleted)
|
||||
return result.RowsAffected, result.Error
|
||||
}
|
||||
|
||||
// UpdateUpload applies partial field updates to an upload record.
|
||||
|
||||
Reference in New Issue
Block a user