优化一个文件缓存统计的Bug

This commit is contained in:
刘祥超
2021-05-19 22:14:57 +08:00
parent 4e04534244
commit 296848a6d6

View File

@@ -230,7 +230,7 @@ func (this *FileList) CleanAll() error {
func (this *FileList) Stat(check func(hash string) bool) (*Stat, error) {
// 这里不设置过期时间、不使用 check 函数,目的是让查询更快速一些
row := this.db.QueryRow("SELECT COUNT(*), SUM(headerSize+bodySize+metaSize), SUM(headerSize+bodySize) FROM cacheItems")
row := this.db.QueryRow("SELECT COUNT(*), IFNULL(SUM(headerSize+bodySize+metaSize), 0), IFNULL(SUM(headerSize+bodySize), 0) FROM cacheItems")
if row.Err() != nil {
return nil, row.Err()
}