fix(auth): address Task 13 deployment review findings
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
//go:build !windows
|
||||
|
||||
package backup
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func restoreFreeBytes(target string) (uint64, error) {
|
||||
var statistics unix.Statfs_t
|
||||
if err := unix.Statfs(target, &statistics); err != nil {
|
||||
return 0, errors.New("restore filesystem capacity is unavailable")
|
||||
}
|
||||
blockSize := uint64(statistics.Bsize)
|
||||
available := uint64(statistics.Bavail)
|
||||
if blockSize != 0 && available > ^uint64(0)/blockSize {
|
||||
return 0, errors.New("restore filesystem capacity is invalid")
|
||||
}
|
||||
return blockSize * available, nil
|
||||
}
|
||||
Reference in New Issue
Block a user