This commit is contained in:
toom1996
2026-09-30 11:58:32 +08:00
parent 065d57457e
commit 1b06bd5bda
24 changed files with 2588 additions and 1659 deletions

View File

@ -300,6 +300,11 @@ func (s *articleService) DeleteImage(ctx context.Context, imageID uint32) error
log.Printf("[warn] 重算走秀 %d 去重失败(重复标记可能陈旧): %v", runwayID, err)
}
}
// 跨文章清理:本图若是其它文章近重复的「源」,那些文章的 dup_of 需重算/清除
// (ReresolveRunwayDedup 只算本集内,不会碰其它文章指向本图的标记)。
if err := s.articles.ReresolveRunwayDupOfSources(ctx, []uint32{imageID}); err != nil {
log.Printf("[warn] 跨文章重算走秀图 %d 去重失败(重复标记可能陈旧): %v", imageID, err)
}
return nil
}
@ -329,6 +334,11 @@ func (s *articleService) SetDeleted(ctx context.Context, id uint32, deleted uint
// 仍被其他图集引用的 key 不会被误删(内容寻址共享 key 安全);入队失败仅告警,
// 图集已下架、图片已软删,S4文件留待后续手动清理或周期性兜底扫描。
func (s *articleService) PurgeGallery(ctx context.Context, id uint32) error {
// 下架前先取存活图片 id:删整篇后,其它文章中 dup_of 指向本篇图片的标记需跨文章重算/清除。
delIDs, err := s.articles.GetRunwayLiveImageIDs(ctx, id)
if err != nil {
return err
}
keys, err := s.articles.SoftDeleteRunwayImages(ctx, id)
if err != nil {
return err
@ -341,6 +351,12 @@ func (s *articleService) PurgeGallery(ctx context.Context, id uint32) error {
log.Printf("[warn] 下架图集 %d 入队清理S4失败(文件将暂留): %v", id, err)
}
}
// 跨文章去重清理:删除整篇后,其它文章中 dup_of 指向本篇图片的标记重算/清除。
if len(delIDs) > 0 {
if err := s.articles.ReresolveRunwayDupOfSources(ctx, delIDs); err != nil {
log.Printf("[warn] 跨文章重算走秀 %d 去重失败(重复标记可能陈旧): %v", id, err)
}
}
return nil
}