mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-11-25 03:15:19 +08:00
* fix(local): assign non-CoW copy requests to the task module * fix build * fix cross device
36 lines
672 B
Go
36 lines
672 B
Go
//go:build !windows
|
|
|
|
package local
|
|
|
|
import (
|
|
"errors"
|
|
"io/fs"
|
|
"strings"
|
|
"syscall"
|
|
|
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func isHidden(f fs.FileInfo, _ string) bool {
|
|
return strings.HasPrefix(f.Name(), ".")
|
|
}
|
|
|
|
func getDiskUsage(path string) (model.DiskUsage, error) {
|
|
var stat syscall.Statfs_t
|
|
err := syscall.Statfs(path, &stat)
|
|
if err != nil {
|
|
return model.DiskUsage{}, err
|
|
}
|
|
total := stat.Blocks * uint64(stat.Bsize)
|
|
free := stat.Bfree * uint64(stat.Bsize)
|
|
return model.DiskUsage{
|
|
TotalSpace: total,
|
|
FreeSpace: free,
|
|
}, nil
|
|
}
|
|
|
|
func isCrossDeviceError(err error) bool {
|
|
return errors.Is(err, unix.EXDEV)
|
|
}
|