git » gofer » commit b95a0ba

dir: Don't wrap regular files

author Alberto Bertogli
2020-06-09 10:52:54 UTC
committer Alberto Bertogli
2020-06-09 10:52:54 UTC
parent c797d7eb0075c4c09d73505a90c2ef31d28e0056

dir: Don't wrap regular files

There is no need to wrap regular files, since the only thing we wrap them
for is Readdir.

server/dir.go +5 -5

diff --git a/server/dir.go b/server/dir.go
index bb809b7..ec9b215 100644
--- a/server/dir.go
+++ b/server/dir.go
@@ -53,14 +53,14 @@ func (fs *FileSystem) Open(name string) (http.File, error) {
 		return nil, err
 	}
 
-	f = wrappedFile{File: f, name: name, opts: &fs.opts}
-
-	if ListingEnabled(&fs.opts, name) {
+	// If it's not a directory, let it be.
+	if s, _ := f.Stat(); s == nil || !s.IsDir() {
 		return f, nil
 	}
 
-	// If it's not a directory, let it be.
-	if s, _ := f.Stat(); s == nil || !s.IsDir() {
+	f = wrappedFile{File: f, name: name, opts: &fs.opts}
+
+	if ListingEnabled(&fs.opts, name) {
 		return f, nil
 	}