From b69c78b380e857f2cd6fc99b882b5ceee02a49ab Mon Sep 17 00:00:00 2001 From: ston1th Date: Fri, 3 Jun 2022 23:37:29 +0200 Subject: [PATCH] cache file open bugfix --- pkg/fs/fs.go | 5 +++-- pkg/srv/srv.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/fs/fs.go b/pkg/fs/fs.go index 313e1c2..5aceca9 100644 --- a/pkg/fs/fs.go +++ b/pkg/fs/fs.go @@ -199,14 +199,15 @@ func (fs *FS) Open(name string) (f http.File, err error) { f = &Dir{log: log.WithName("dir"), f: file, dc: fs.dc} return } - md := fs.mh.Metadata(name, fi.Size()) + size := fi.Size() + md := fs.mh.Metadata(name, size) var cache provider.File if offline { log.V(2).Info("file offline mode") cache = file } else { - cache, err = fs.dst.Open(name) + cache, err = fs.openCacheFile(name, size) if err != nil { if !skipLog(name) { log.Error(err, "error opening cache file") diff --git a/pkg/srv/srv.go b/pkg/srv/srv.go index f1808a5..3091382 100644 --- a/pkg/srv/srv.go +++ b/pkg/srv/srv.go @@ -48,7 +48,7 @@ func skipLog(path string) bool { func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { s := &statusInterceptor{w: w} w = s - if !skipLog(r.RequestURI) { + if !skipLog(r.URL.Path) { defer func() { if s.Status() == http.StatusPartialContent { return @@ -57,7 +57,7 @@ func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { "client", r.RemoteAddr, "method", r.Method, "status", s.Status(), - "uri", r.RequestURI, + "uri", r.URL.Path, ) }() }