File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -131,12 +131,6 @@ func newApp() *cobra.Command {
131131 if err != nil {
132132 return err
133133 }
134- // Make sure that directory is on a local filesystem, not on NFS
135- // if the directory does not yet exist, check the home directory
136- _ , err = os .Stat (dir )
137- if errors .Is (err , os .ErrNotExist ) {
138- dir = filepath .Dir (dir )
139- }
140134 nfs , err := fsutil .IsNFS (dir )
141135 if err != nil {
142136 return err
Original file line number Diff line number Diff line change 44package fsutil
55
66import (
7+ "errors"
8+ "os"
9+ "path/filepath"
10+
711 "golang.org/x/sys/unix"
812)
913
14+ // IsNFS checks if the path is on NFS. If the path does not exist yet, it will walk
15+ // up parent directories until one exists, or it hits '/' or '.'.
16+ // Any other stat errors will cause IsNFS to fail.
1017func IsNFS (path string ) (bool , error ) {
18+ for len (path ) > 1 {
19+ _ , err := os .Stat (path )
20+ if err == nil {
21+ break
22+ }
23+ if ! errors .Is (err , os .ErrNotExist ) {
24+ return false , err
25+ }
26+ path = filepath .Dir (path )
27+ }
28+
1129 var sf unix.Statfs_t
1230 if err := unix .Statfs (path , & sf ); err != nil {
1331 return false , err
You can’t perform that action at this time.
0 commit comments