feat(cli): add login command and refactor shared helpers
This commit is contained in:
parent
0dafeaa70d
commit
4d35e197f0
8 changed files with 296 additions and 49 deletions
25
internal/agent/disk.go
Normal file
25
internal/agent/disk.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package agent
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// DirSize returns the total size in bytes of all files under dir.
|
||||
func DirSize(dir string) (int64, error) {
|
||||
var size int64
|
||||
err := filepath.WalkDir(dir, func(_ string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return nil // skip unreadable entries
|
||||
}
|
||||
if !d.IsDir() {
|
||||
info, err := d.Info()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
size += info.Size()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return size, err
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue