[arvados] updated: 2.4.2-23-g97614d589

git repository hosting git at public.arvados.org
Fri Sep 16 18:13:47 UTC 2022


Summary of changes:
 services/keep-web/handler.go | 55 ++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 28 deletions(-)

       via  97614d5895fc8709c8a18130977bc25414c9dbca (commit)
      from  8ad66154df528ad2020e80bc255896537f1c712a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 97614d5895fc8709c8a18130977bc25414c9dbca
Author: Tom Clegg <tom at curii.com>
Date:   Fri Sep 16 11:19:40 2022 -0400

    19368: cherry-pick 19368-webdav-logging-speedup onto 2.4-staging
    
    from a20fa9a88926637a641699cec7dda31e54760622 on main
    
    refs #19368
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/services/keep-web/handler.go b/services/keep-web/handler.go
index ef61b0687..d7796d44d 100644
--- a/services/keep-web/handler.go
+++ b/services/keep-web/handler.go
@@ -909,17 +909,18 @@ func (h *handler) logUploadOrDownload(
 		collection, filepath = h.determineCollection(fs, filepath)
 	}
 	if collection != nil {
-		log = log.WithField("collection_uuid", collection.UUID).
-			WithField("collection_file_path", filepath)
-		props["collection_uuid"] = collection.UUID
+		log = log.WithField("collection_file_path", filepath)
 		props["collection_file_path"] = filepath
-		// h.determineCollection populates the collection_uuid prop with the PDH, if
-		// this collection is being accessed via PDH. In that case, blank the
-		// collection_uuid field so that consumers of the log entries can rely on it
-		// being a UUID, or blank. The PDH remains available via the
-		// portable_data_hash property.
-		if props["collection_uuid"] == collection.PortableDataHash {
-			props["collection_uuid"] = ""
+		// h.determineCollection populates the collection_uuid
+		// prop with the PDH, if this collection is being
+		// accessed via PDH. For logging, we use a different
+		// field depending on whether it's a UUID or PDH.
+		if len(collection.UUID) > 32 {
+			log = log.WithField("portable_data_hash", collection.UUID)
+			props["portable_data_hash"] = collection.UUID
+		} else {
+			log = log.WithField("collection_uuid", collection.UUID)
+			props["collection_uuid"] = collection.UUID
 		}
 	}
 	if r.Method == "PUT" || r.Method == "POST" {
@@ -958,29 +959,27 @@ func (h *handler) logUploadOrDownload(
 }
 
 func (h *handler) determineCollection(fs arvados.CustomFileSystem, path string) (*arvados.Collection, string) {
-	segments := strings.Split(path, "/")
-	var i int
-	for i = 0; i < len(segments); i++ {
-		dir := append([]string{}, segments[0:i]...)
-		dir = append(dir, ".arvados#collection")
-		f, err := fs.OpenFile(strings.Join(dir, "/"), os.O_RDONLY, 0)
-		if f != nil {
-			defer f.Close()
-		}
+	target := strings.TrimSuffix(path, "/")
+	for {
+		fi, err := fs.Stat(target)
 		if err != nil {
-			if !os.IsNotExist(err) {
+			return nil, ""
+		}
+		switch src := fi.Sys().(type) {
+		case *arvados.Collection:
+			return src, strings.TrimPrefix(path[len(target):], "/")
+		case *arvados.Group:
+			return nil, ""
+		default:
+			if _, ok := src.(error); ok {
 				return nil, ""
 			}
-			continue
 		}
-		// err is nil so we found it.
-		decoder := json.NewDecoder(f)
-		var collection arvados.Collection
-		err = decoder.Decode(&collection)
-		if err != nil {
+		// Try parent
+		cut := strings.LastIndexByte(target, '/')
+		if cut < 0 {
 			return nil, ""
 		}
-		return &collection, strings.Join(segments[i:], "/")
+		target = target[:cut]
 	}
-	return nil, ""
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list