@@ -40,9 +40,7 @@ import (
40
40
41
41
// Path represents a path
42
42
type Path struct {
43
- path string
44
- cachedFileInfo os.FileInfo
45
- cachedFileInfoTime time.Time
43
+ path string
46
44
}
47
45
48
46
// New creates a new Path object. If path is the empty string
@@ -64,30 +62,11 @@ func NewFromFile(file *os.File) *Path {
64
62
return New (file .Name ())
65
63
}
66
64
67
- func (p * Path ) setCachedFileInfo (info os.FileInfo ) {
68
- p .cachedFileInfo = info
69
- p .cachedFileInfoTime = time .Now ()
70
- }
71
-
72
65
// Stat returns a FileInfo describing the named file. The result is
73
66
// cached internally for next queries. To ensure that the cached
74
67
// FileInfo entry is updated just call Stat again.
75
68
func (p * Path ) Stat () (os.FileInfo , error ) {
76
- info , err := os .Stat (p .path )
77
- if err != nil {
78
- return nil , err
79
- }
80
- p .setCachedFileInfo (info )
81
- return info , nil
82
- }
83
-
84
- func (p * Path ) stat () (os.FileInfo , error ) {
85
- if p .cachedFileInfo != nil {
86
- if p .cachedFileInfoTime .Add (50 * time .Millisecond ).After (time .Now ()) {
87
- return p .cachedFileInfo , nil
88
- }
89
- }
90
- return p .Stat ()
69
+ return os .Stat (p .path )
91
70
}
92
71
93
72
// Clone create a copy of the Path object
@@ -226,13 +205,12 @@ func (p *Path) FollowSymLink() error {
226
205
return err
227
206
}
228
207
p .path = resolvedPath
229
- p .cachedFileInfo = nil
230
208
return nil
231
209
}
232
210
233
211
// Exist return true if the path exists
234
212
func (p * Path ) Exist () (bool , error ) {
235
- _ , err := p .stat ()
213
+ _ , err := p .Stat ()
236
214
if err == nil {
237
215
return true , nil
238
216
}
@@ -244,7 +222,7 @@ func (p *Path) Exist() (bool, error) {
244
222
245
223
// IsDir return true if the path exists and is a directory
246
224
func (p * Path ) IsDir () (bool , error ) {
247
- info , err := p .stat ()
225
+ info , err := p .Stat ()
248
226
if err == nil {
249
227
return info .IsDir (), nil
250
228
}
@@ -264,7 +242,6 @@ func (p *Path) ReadDir() (PathList, error) {
264
242
paths := PathList {}
265
243
for _ , info := range infos {
266
244
path := p .Clone ().Join (info .Name ())
267
- path .setCachedFileInfo (info )
268
245
paths .Add (path )
269
246
}
270
247
return paths , nil
0 commit comments