cache file open bugfix
This commit is contained in:
parent
76a2f7d2db
commit
b69c78b380
2 changed files with 5 additions and 4 deletions
|
|
@ -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}
|
f = &Dir{log: log.WithName("dir"), f: file, dc: fs.dc}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
md := fs.mh.Metadata(name, fi.Size())
|
size := fi.Size()
|
||||||
|
md := fs.mh.Metadata(name, size)
|
||||||
|
|
||||||
var cache provider.File
|
var cache provider.File
|
||||||
if offline {
|
if offline {
|
||||||
log.V(2).Info("file offline mode")
|
log.V(2).Info("file offline mode")
|
||||||
cache = file
|
cache = file
|
||||||
} else {
|
} else {
|
||||||
cache, err = fs.dst.Open(name)
|
cache, err = fs.openCacheFile(name, size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !skipLog(name) {
|
if !skipLog(name) {
|
||||||
log.Error(err, "error opening cache file")
|
log.Error(err, "error opening cache file")
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ func skipLog(path string) bool {
|
||||||
func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
s := &statusInterceptor{w: w}
|
s := &statusInterceptor{w: w}
|
||||||
w = s
|
w = s
|
||||||
if !skipLog(r.RequestURI) {
|
if !skipLog(r.URL.Path) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if s.Status() == http.StatusPartialContent {
|
if s.Status() == http.StatusPartialContent {
|
||||||
return
|
return
|
||||||
|
|
@ -57,7 +57,7 @@ func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
"client", r.RemoteAddr,
|
"client", r.RemoteAddr,
|
||||||
"method", r.Method,
|
"method", r.Method,
|
||||||
"status", s.Status(),
|
"status", s.Status(),
|
||||||
"uri", r.RequestURI,
|
"uri", r.URL.Path,
|
||||||
)
|
)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue