Skip to content

Commit

Permalink
google drive rawFile when thumb failed
Browse files Browse the repository at this point in the history
  • Loading branch information
lovehunter9 committed Dec 6, 2024
1 parent fd013aa commit 1e8a179
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
3 changes: 0 additions & 3 deletions packages/backend/http/google_drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -2135,9 +2135,6 @@ func handleImagePreviewGoogle(
return errToStatus(os.ErrPermission), os.ErrPermission
}

// for test
return rawFileHandlerGoogle(src, w, r, file, bflName)

if (previewSize == PreviewSizeBig && !resizePreview) ||
(previewSize == PreviewSizeThumb && !enableThumbnails) {
return rawFileHandlerGoogle(src, w, r, file, bflName)
Expand Down
15 changes: 8 additions & 7 deletions packages/backend/my_redis/file_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ func DelThumbRedisKey(key string) error {

// 每天定时清理过期文件和Redis ZSET成员
func StartDailyCleanup() {
cycle := time.Minute * 5
cycle := time.Hour // time.Minute * 5
ticker := time.NewTicker(cycle)
defer ticker.Stop()

// 在下一次整点时触发
//now := time.Now()
//nextCleanupTime := time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 0, 0, 0, now.Location()).Add(cycle)
//duration := nextCleanupTime.Sub(now)
//time.Sleep(duration)
now := time.Now()
nextCleanupTime := time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 0, 0, 0, now.Location()).Add(cycle)
duration := nextCleanupTime.Sub(now)
time.Sleep(duration)

for range ticker.C {
cleanupMux.Lock()
CleanupOldFilesAndRedisEntries(cycle)
CleanupOldFilesAndRedisEntries(1 * cycle)
cleanupMux.Unlock()
}
}
Expand All @@ -72,7 +72,8 @@ func CleanupOldFilesAndRedisEntries(duration time.Duration) {
err = os.Remove(filePath)
if err != nil {
fmt.Println("Error deleting file:", err)
continue
// if file delete failed, key will also be removed
//continue
}

// 从Redis ZSET中删除成员
Expand Down

0 comments on commit 1e8a179

Please sign in to comment.