优化缩略图

This commit is contained in:
truewhile
2026-09-20 15:16:40 +08:00
parent c24ebe181d
commit 47899284a5
27 changed files with 1959 additions and 244 deletions
+6 -5
View File
@@ -178,18 +178,19 @@ func (s *SchedulerService) jobCleanTranscodeCache(ctx context.Context) error {
return walkAndPrune(s.cacheDir+"/hls", cutoff)
}
// jobCleanImageCache prunes image proxy cache files when disk usage exceeds the configured limit.
// jobCleanImageCache prunes the image proxy cache: 原图按保留时长与独立配额
// 优先淘汰,总量超限时再淘汰派生成品。
func (s *SchedulerService) jobCleanImageCache(ctx context.Context) error {
if s.cacheDir == "" {
return nil
}
maxMB := s.imagesMaxSizeMB()
if maxMB <= 0 {
policy := s.imageCachePolicy()
if policy.TotalBytes <= 0 && policy.OriginalsBytes <= 0 && policy.OriginalsAge <= 0 {
return nil
}
imagesDir := filepath.Join(s.cacheDir, "images")
maxSizeBytes := int64(maxMB) * 1024 * 1024
res, err := PruneImageCache(imagesDir, maxSizeBytes)
pools := ImageCachePools(imagesDir, policy.OriginalsBytes, policy.OriginalsAge)
res, err := PruneImageCachePools(pools, policy.TotalBytes)
if err != nil {
if s.log != nil {
s.log.Warn("scheduled image cache cleanup failed", zap.Error(err))