diff --git a/internal/pkg/cacheclient/cacheclient.go b/internal/pkg/cacheclient/cacheclient.go index 9e9cba8..f8b6cf5 100644 --- a/internal/pkg/cacheclient/cacheclient.go +++ b/internal/pkg/cacheclient/cacheclient.go @@ -5,6 +5,7 @@ import ( "github.com/hashicorp/golang-lru/v2/expirable" "github.com/rs/zerolog/log" "io/fs" + "path/filepath" "readnetfs/internal/pkg/fsclient" "sync" "syscall" @@ -105,9 +106,12 @@ func (c *CacheClient) ReadDir(path fsclient.RemotePath) ([]fs.FileInfo, error) { } func (c *CacheClient) FileInfo(path fsclient.RemotePath) (fs.FileInfo, error) { + //trigger parent dir read to fill cache for future requests + go c.ReadDir(fsclient.RemotePath(filepath.Dir(string(path)))) if info, ok := c.infos.Get(path); ok { return info, nil } + log.Warn().Msgf("reading single file info from %s", path) c.infoLock.Lock() defer c.infoLock.Unlock() info, err := c.client.FileInfo(path) diff --git a/internal/pkg/netclient/netclient.go b/internal/pkg/netclient/netclient.go index f999819..7732749 100644 --- a/internal/pkg/netclient/netclient.go +++ b/internal/pkg/netclient/netclient.go @@ -11,7 +11,6 @@ import ( "io/fs" "math" "net" - "path/filepath" "readnetfs/internal/pkg/cacheclient" "readnetfs/internal/pkg/common" "readnetfs/internal/pkg/fsclient" @@ -176,8 +175,6 @@ func (f *NetClient) FileInfo(path fsclient.RemotePath) (fs.FileInfo, error) { return info, nil } } - //trigger parent dir read to fill cache for future requests - go f.ReadDir(fsclient.RemotePath(filepath.Dir(string(path)))) _, _ = fmt.Fprintf(f.statsdSocket, "requests.outgoing.file_info:1|c\n") return nil, errors.New("no peer has file" + string(path)) }