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 @@ -134,12 +134,6 @@ func newApp() *cobra.Command {
134
134
if err != nil {
135
135
return err
136
136
}
137
- // Make sure that directory is on a local filesystem, not on NFS
138
- // if the directory does not yet exist, check the home directory
139
- _ , err = os .Stat (dir )
140
- if errors .Is (err , os .ErrNotExist ) {
141
- dir = filepath .Dir (dir )
142
- }
143
137
nfs , err := fsutil .IsNFS (dir )
144
138
if err != nil {
145
139
return err
Original file line number Diff line number Diff line change 4
4
package fsutil
5
5
6
6
import (
7
+ "errors"
8
+ "os"
9
+ "path/filepath"
10
+
7
11
"golang.org/x/sys/unix"
8
12
)
9
13
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.
10
17
func 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
+
11
29
var sf unix.Statfs_t
12
30
if err := unix .Statfs (path , & sf ); err != nil {
13
31
return false , err
You can’t perform that action at this time.
0 commit comments