mirror of
https://github.com/samuelncui/acp.git
synced 2025-12-23 05:05:15 +00:00
fix: fs syscall
This commit is contained in:
18
autofill.go
18
autofill.go
@@ -19,8 +19,8 @@ func (c *Copyer) applyAutoFillLimit() error {
|
||||
return fmt.Errorf("get file system fail, %s, %w", d, err)
|
||||
}
|
||||
|
||||
infos[fsInfo.MountPoint] = fsInfo
|
||||
counts[fsInfo.MountPoint] = counts[fsInfo.MountPoint] + 1
|
||||
infos[d] = fsInfo
|
||||
counts[d] = counts[d] + 1
|
||||
}
|
||||
|
||||
min := int64(math.MaxInt64)
|
||||
@@ -46,19 +46,15 @@ func (c *Copyer) applyAutoFillLimit() error {
|
||||
c.jobs = c.jobs[:idx]
|
||||
last := ""
|
||||
for _, job := range cutoff {
|
||||
job.parent.done(job)
|
||||
|
||||
if job.parent != nil {
|
||||
job.parent.done(job)
|
||||
}
|
||||
if strings.HasPrefix(job.source.relativePath, last) {
|
||||
if len(job.source.relativePath) == len(last) {
|
||||
continue
|
||||
}
|
||||
if job.source.relativePath[len(last)] == '/' {
|
||||
continue
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
c.noSpaceSource = append(c.noSpaceSource, job.source)
|
||||
last = job.source.relativePath
|
||||
last = job.source.relativePath + "/"
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
16
fs.go
16
fs.go
@@ -2,26 +2,26 @@ package acp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
type fileSystem struct {
|
||||
TypeName string
|
||||
MountPoint string
|
||||
// TypeName string
|
||||
// MountPoint string
|
||||
TotalSize int64
|
||||
AvailableSize int64
|
||||
}
|
||||
|
||||
func getFileSystem(path string) (*fileSystem, error) {
|
||||
stat := new(syscall.Statfs_t)
|
||||
|
||||
if err := syscall.Statfs(path, stat); err != nil {
|
||||
stat := new(unix.Statfs_t)
|
||||
if err := unix.Statfs(path, stat); err != nil {
|
||||
return nil, fmt.Errorf("read statfs fail, err= %w", err)
|
||||
}
|
||||
|
||||
return &fileSystem{
|
||||
TypeName: unpaddingInt8s(stat.Fstypename[:]),
|
||||
MountPoint: unpaddingInt8s(stat.Mntonname[:]),
|
||||
// TypeName: unpaddingInt8s(stat.Fstypename[:]),
|
||||
// MountPoint: unpaddingInt8s(stat.Mntonname[:]),
|
||||
TotalSize: int64(stat.Blocks) * int64(stat.Bsize),
|
||||
AvailableSize: int64(stat.Bavail) * int64(stat.Bsize),
|
||||
}, nil
|
||||
|
||||
Reference in New Issue
Block a user