mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-13 16:46:37 +08:00
优化缩略图
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user