hand dirCacheTime through again
This commit is contained in:
parent
9cede6b372
commit
9782c264e9
4 changed files with 16 additions and 8 deletions
|
@ -51,6 +51,7 @@ func NewFS(f fs.Fs) *FS {
|
|||
if pollInterval > 0 {
|
||||
fsys.FS.PollChanges(pollInterval)
|
||||
}
|
||||
fsys.FS.SetDirCacheTime(dirCacheTime)
|
||||
return fsys
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ func NewFS(f fs.Fs) *FS {
|
|||
if pollInterval > 0 {
|
||||
fsys.FS.PollChanges(pollInterval)
|
||||
}
|
||||
fsys.FS.SetDirCacheTime(dirCacheTime)
|
||||
return fsys
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,6 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var dirCacheTime = 60 * time.Second // FIXME needs to be settable
|
||||
|
||||
// DirEntry describes the contents of a directory entry
|
||||
//
|
||||
// It can be a file or a directory
|
||||
|
@ -152,7 +150,7 @@ func (d *Dir) readDir() error {
|
|||
// fs.Debugf(d.path, "Reading directory")
|
||||
} else {
|
||||
age := when.Sub(d.read)
|
||||
if age < dirCacheTime {
|
||||
if age < d.fsys.dirCacheTime {
|
||||
return nil
|
||||
}
|
||||
fs.Debugf(d.path, "Re-reading directory (%v old)", age)
|
||||
|
|
|
@ -35,11 +35,12 @@ var (
|
|||
|
||||
// FS represents the top level filing system
|
||||
type FS struct {
|
||||
f fs.Fs
|
||||
root *Dir
|
||||
noSeek bool // don't allow seeking if set
|
||||
noChecksum bool // don't check checksums if set
|
||||
readOnly bool // if set FS is read only
|
||||
f fs.Fs
|
||||
root *Dir
|
||||
noSeek bool // don't allow seeking if set
|
||||
noChecksum bool // don't check checksums if set
|
||||
readOnly bool // if set FS is read only
|
||||
dirCacheTime time.Duration // how long to consider directory listing cache valid
|
||||
}
|
||||
|
||||
// NewFS creates a new filing system and root directory
|
||||
|
@ -57,6 +58,13 @@ func NewFS(f fs.Fs) *FS {
|
|||
return fsys
|
||||
}
|
||||
|
||||
// SetDirCacheTime allows to set how long a directory listing is considered
|
||||
// valid. Set to 0 always request a fresh version from the remote.
|
||||
func (fsys *FS) SetDirCacheTime(dirCacheTime time.Duration) *FS {
|
||||
fsys.dirCacheTime = dirCacheTime
|
||||
return fsys
|
||||
}
|
||||
|
||||
// PollChanges will poll the remote every pollInterval for changes if the remote
|
||||
// supports it. If a non-polling option is used, the given time interval can be
|
||||
// ignored
|
||||
|
|
Loading…
Reference in a new issue