mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-07 08:15:49 +08:00
检查硬盘是否已满时同时检测缓存策略中定义的容量
This commit is contained in:
@@ -1418,7 +1418,7 @@ func (this *FileStorage) initOpenFileCache() {
|
||||
}
|
||||
|
||||
func (this *FileStorage) runMemoryStorageSafety(f func(memoryStorage *MemoryStorage)) {
|
||||
var memoryStorage = this.memoryStorage
|
||||
var memoryStorage = this.memoryStorage // copy
|
||||
if memoryStorage != nil {
|
||||
f(memoryStorage)
|
||||
}
|
||||
@@ -1437,6 +1437,15 @@ func (this *FileStorage) checkDiskSpace() {
|
||||
stat, err := fsutils.StatDevice(options.Dir)
|
||||
if err == nil {
|
||||
this.mainDiskIsFull = stat.FreeSize() < minFreeSize
|
||||
|
||||
// check capacity (only on main directory)
|
||||
var policy = this.policy // copy
|
||||
if !this.mainDiskIsFull && policy != nil {
|
||||
var capacityBytes = policy.CapacityBytes() // copy
|
||||
if capacityBytes > 0 && stat.UsedSize() >= uint64(capacityBytes) {
|
||||
this.mainDiskIsFull = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var subDirs = this.subDirs // copy slice
|
||||
|
||||
Reference in New Issue
Block a user