From 12631a3f5b85e438b312b02bac044617fa106f45 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 23 Aug 2021 14:43:01 -0700 Subject: [PATCH] cloud drive: gcs simplify a little bit --- weed/remote_storage/gcs/gcs_storage_client.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/weed/remote_storage/gcs/gcs_storage_client.go b/weed/remote_storage/gcs/gcs_storage_client.go index dd9fd2df6..9ca583b21 100644 --- a/weed/remote_storage/gcs/gcs_storage_client.go +++ b/weed/remote_storage/gcs/gcs_storage_client.go @@ -110,24 +110,16 @@ func (gcs *gcsRemoteStorageClient) WriteFile(loc *filer_pb.RemoteStorageLocation key := loc.Path[1:] + metadata := toMetadata(entry.Extended) wc := gcs.client.Bucket(loc.Bucket).Object(key).NewWriter(context.Background()) + wc.Metadata = metadata if _, err = io.Copy(wc, reader); err != nil { - wc.Close() return nil, fmt.Errorf("upload to gcs %s/%s%s: %v", loc.Name, loc.Bucket, loc.Path, err) } if err = wc.Close(); err != nil { return nil, fmt.Errorf("close gcs %s/%s%s: %v", loc.Name, loc.Bucket, loc.Path, err) } - metadata := toMetadata(entry.Extended) - if len(metadata) > 0 { - if _, err = gcs.client.Bucket(loc.Bucket).Object(key).Update(context.Background(), storage.ObjectAttrsToUpdate{ - Metadata: metadata, - }); err != nil { - return nil, fmt.Errorf("update metadata gcs %s/%s%s: %v", loc.Name, loc.Bucket, loc.Path, err) - } - } - // read back the remote entry return gcs.readFileRemoteEntry(loc)