12715: Rename flag !reading => alwaysReadEOF.
authorTom Clegg <tclegg@veritasgenetics.com>
Fri, 15 Dec 2017 15:14:13 +0000 (10:14 -0500)
committerTom Clegg <tclegg@veritasgenetics.com>
Fri, 15 Dec 2017 15:15:58 +0000 (10:15 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

services/keep-web/handler.go
services/keep-web/webdav.go

index 4cb2fdba821e8bca5f8b635390d9bf9a6cae556a..19a2040b4a5735551c0f7bf8a610c1fb109399b9 100644 (file)
@@ -441,9 +441,9 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
                h := webdav.Handler{
                        Prefix: "/" + strings.Join(pathParts[:stripParts], "/"),
                        FileSystem: &webdavFS{
-                               collfs:  fs,
-                               writing: writeMethod[r.Method],
-                               reading: r.Method != "PROPFIND",
+                               collfs:        fs,
+                               writing:       writeMethod[r.Method],
+                               alwaysReadEOF: r.Method == "PROPFIND",
                        },
                        LockSystem: h.webdavLS,
                        Logger: func(_ *http.Request, err error) {
index 98e6f01987b5de971e005eb1d471b82a5615d3ac..af83681f9c4b435285ebe1e6f3b9c1a1f7a807a4 100644 (file)
@@ -38,7 +38,12 @@ var (
 type webdavFS struct {
        collfs  arvados.CollectionFileSystem
        writing bool
-       reading bool
+       // webdav PROPFIND reads the first few bytes of each file
+       // whose filename extension isn't recognized, which is
+       // prohibitively expensive: we end up fetching multiple 64MiB
+       // blocks. Avoid this by returning EOF on all reads when
+       // handling a PROPFIND.
+       alwaysReadEOF bool
 }
 
 func (fs *webdavFS) makeparents(name string) {
@@ -73,13 +78,7 @@ func (fs *webdavFS) OpenFile(ctx context.Context, name string, flag int, perm os
                // have 405.
                f = writeFailer{File: f, err: errReadOnly}
        }
-       if !fs.reading {
-               // webdav PROPFIND reads the first few bytes of each
-               // file whose filename extension isn't recognized,
-               // which is prohibitively expensive: we end up
-               // fetching multiple 64MiB blocks. Avoid this by
-               // returning EOF on all reads when handling a
-               // PROPFIND.
+       if fs.alwaysReadEOF {
                f = readEOF{File: f}
        }
        return