From 5c9023ddf1e7d03a2b23390dd1461429c666d67a Mon Sep 17 00:00:00 2001 From: AJ Roetker Date: Tue, 10 Mar 2020 11:13:04 -0700 Subject: [PATCH 1/2] Add size to metadata in google driver --- google/store.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/google/store.go b/google/store.go index 8449965..26409b6 100644 --- a/google/store.go +++ b/google/store.go @@ -6,6 +6,7 @@ import ( "io" "os" "path" + "strconv" "strings" "time" @@ -308,10 +309,12 @@ type object struct { } func newObject(g *GcsFS, o *storage.ObjectAttrs) *object { + metadata := o.Metadata + metadata["content_length"] = strconv.FormatInt(o.Size, 10) return &object{ name: o.Name, updated: o.Updated, - metadata: o.Metadata, + metadata: metadata, gcsb: g.gcsb(), bucket: g.bucket, cachepath: cloudstorage.CachePathObj(g.cachepath, o.Name, g.Id), From 063773921bfcfa53cb8d88abe1b42e0832842ea2 Mon Sep 17 00:00:00 2001 From: AJ Roetker Date: Tue, 10 Mar 2020 12:10:47 -0700 Subject: [PATCH 2/2] Create metadata map if one doesn't exist for gcs --- google/store.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/google/store.go b/google/store.go index 26409b6..8eccb06 100644 --- a/google/store.go +++ b/google/store.go @@ -310,6 +310,9 @@ type object struct { func newObject(g *GcsFS, o *storage.ObjectAttrs) *object { metadata := o.Metadata + if metadata == nil { + metadata = make(map[string]string) + } metadata["content_length"] = strconv.FormatInt(o.Size, 10) return &object{ name: o.Name,