mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-11 22:00:25 +08:00
如果设置的缓存容量比当前磁盘总容量大的时候,自动调整为95%磁盘总容量
This commit is contained in:
@@ -90,6 +90,7 @@ type FileStorage struct {
|
|||||||
openFileCache *OpenFileCache
|
openFileCache *OpenFileCache
|
||||||
|
|
||||||
mainDiskIsFull bool
|
mainDiskIsFull bool
|
||||||
|
mainDiskTotalSize uint64
|
||||||
|
|
||||||
subDirs []*FileDir
|
subDirs []*FileDir
|
||||||
}
|
}
|
||||||
@@ -1301,9 +1302,17 @@ func (this *FileStorage) diskCapacityBytes() int64 {
|
|||||||
if nodeCapacity != nil {
|
if nodeCapacity != nil {
|
||||||
var c2 = nodeCapacity.Bytes()
|
var c2 = nodeCapacity.Bytes()
|
||||||
if c2 > 0 {
|
if c2 > 0 {
|
||||||
|
if this.mainDiskTotalSize > 0 && c2 >= int64(this.mainDiskTotalSize) {
|
||||||
|
c2 = int64(this.mainDiskTotalSize) * 95 / 100 // keep 5% free
|
||||||
|
}
|
||||||
return c2
|
return c2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c1 <= 0 || (this.mainDiskTotalSize > 0 && c1 >= int64(this.mainDiskTotalSize)) {
|
||||||
|
c1 = int64(this.mainDiskTotalSize) * 95 / 100 // keep 5% free
|
||||||
|
}
|
||||||
|
|
||||||
return c1
|
return c1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1511,6 +1520,7 @@ func (this *FileStorage) checkDiskSpace() {
|
|||||||
stat, err := fsutils.StatDevice(options.Dir)
|
stat, err := fsutils.StatDevice(options.Dir)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
this.mainDiskIsFull = stat.FreeSize() < minFreeSize
|
this.mainDiskIsFull = stat.FreeSize() < minFreeSize
|
||||||
|
this.mainDiskTotalSize = stat.TotalSize()
|
||||||
|
|
||||||
// check capacity (only on main directory) when node capacity had not been set
|
// check capacity (only on main directory) when node capacity had not been set
|
||||||
if !this.mainDiskIsFull {
|
if !this.mainDiskIsFull {
|
||||||
|
|||||||
Reference in New Issue
Block a user