mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
7e1dd8ab9d
See ea9e2b19a5
22 lines
492 B
Go
22 lines
492 B
Go
package fs
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func freeSpace(stat unix.Statfs_t) uint64 {
|
|
return uint64(stat.F_bavail) * uint64(stat.F_bsize)
|
|
}
|
|
|
|
func mustRemoveDirAtomic(dir string) {
|
|
n := atomicDirRemoveCounter.Add(1)
|
|
tmpDir := fmt.Sprintf("%s.must-remove.%d", dir, n)
|
|
if err := os.Rename(dir, tmpDir); err != nil {
|
|
logger.Panicf("FATAL: cannot move %s to %s: %s", dir, tmpDir, err)
|
|
}
|
|
MustRemoveAll(tmpDir)
|
|
}
|