From 98af07b69ce564bec48c5a9edc6d080679ee1c13 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 2 Mar 2024 16:13:08 -0800 Subject: [PATCH] bring back the original progress bar (#4866) also cleanup 'mc put/get' behavior --- .github/workflows/go.yml | 2 +- Makefile | 2 +- cmd/cat-main.go | 11 +++- cmd/client-fs.go | 40 +++++++++++-- cmd/client-fs_test.go | 4 +- cmd/client-s3.go | 32 ++++++++--- cmd/client-s3_test.go | 2 +- cmd/client.go | 3 +- cmd/common-methods.go | 120 +++++++++++---------------------------- cmd/cp-main.go | 22 ++++++- cmd/get-main.go | 12 ++-- cmd/head-main.go | 7 ++- cmd/progress-bar.go | 14 ++--- cmd/put-main.go | 8 ++- cmd/sql-main.go | 7 ++- 15 files changed, 158 insertions(+), 128 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 46ccc90b..f11dce4a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -76,4 +76,4 @@ jobs: - name: Staticcheck # Run with defaults, but allow errors with other formats ST1005 - run: go install honnef.co/go/tools/cmd/staticcheck@latest && staticcheck -tests=false -checks="all,-ST1000,-ST1003,-ST1016,-ST1020,-ST1021,-ST1022,-ST1023,-ST1005" ./... + run: go install honnef.co/go/tools/cmd/staticcheck@latest && make lint diff --git a/Makefile b/Makefile index a2b41c2a..62d72814 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ vet: @echo "Running $@" @GO111MODULE=on go vet github.com/minio/mc/... -lint: +lint: getdeps @echo "Running $@ check" @GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=5m --config ./.golangci.yml @GO111MODULE=on ${GOPATH}/bin/staticcheck -tests=false -checks="all,-ST1000,-ST1003,-ST1016,-ST1020,-ST1021,-ST1022,-ST1023,-ST1005" ./... diff --git a/cmd/cat-main.go b/cmd/cat-main.go index 0d85bb00..131c8682 100644 --- a/cmd/cat-main.go +++ b/cmd/cat-main.go @@ -231,7 +231,15 @@ func catURL(ctx context.Context, sourceURL string, encKeyDB map[string][]prefixS // are ignored since some of them have zero size though they // have contents like files under /proc. // 2. extract the version ID if rewind flag is passed - if client, content, err := url2Stat(ctx, url2StatOptions{urlStr: sourceURL, versionID: o.versionID, fileAttr: false, encKeyDB: encKeyDB, timeRef: o.timeRef, isZip: o.isZip, ignoreBucketExistsCheck: false}); err == nil { + if client, content, err := url2Stat(ctx, url2StatOptions{ + urlStr: sourceURL, + versionID: o.versionID, + fileAttr: false, + encKeyDB: encKeyDB, + timeRef: o.timeRef, + isZip: o.isZip, + ignoreBucketExistsCheck: false, + }); err == nil { if o.versionID == "" { versionID = content.VersionID } @@ -256,7 +264,6 @@ func catURL(ctx context.Context, sourceURL string, encKeyDB map[string][]prefixS gopts := GetOptions{VersionID: versionID, Zip: o.isZip, RangeStart: o.startO} if reader, err = getSourceStreamFromURL(ctx, sourceURL, encKeyDB, getSourceOpts{ GetOptions: gopts, - fetchStat: false, preserve: false, }); err != nil { return err.Trace(sourceURL) diff --git a/cmd/client-fs.go b/cmd/client-fs.go index f36a4d28..2b3e5911 100644 --- a/cmd/client-fs.go +++ b/cmd/client-fs.go @@ -540,21 +540,53 @@ func (f *fsClient) Copy(ctx context.Context, source string, opts CopyOptions, pr } // Get returns reader and any additional metadata. -func (f *fsClient) Get(_ context.Context, opts GetOptions) (io.ReadCloser, *probe.Error) { +func (f *fsClient) Get(_ context.Context, opts GetOptions) (io.ReadCloser, *ClientContent, *probe.Error) { fileData, e := os.Open(f.PathURL.Path) if e != nil { err := f.toClientError(e, f.PathURL.Path) - return nil, err.Trace(f.PathURL.Path) + return nil, nil, err.Trace(f.PathURL.Path) } if opts.RangeStart != 0 { _, e := fileData.Seek(opts.RangeStart, io.SeekStart) if e != nil { err := f.toClientError(e, f.PathURL.Path) - return nil, err.Trace(f.PathURL.Path) + return nil, nil, err.Trace(f.PathURL.Path) } } - return fileData, nil + fi, e := fileData.Stat() + if e != nil { + return nil, nil, probe.NewError(e) + } + + content := &ClientContent{} + content.URL = *f.PathURL + content.Size = fi.Size() + content.Time = fi.ModTime() + content.Type = fi.Mode() + content.Metadata = map[string]string{ + "Content-Type": guessURLContentType(f.PathURL.Path), + } + + path := f.PathURL.String() + // Populates meta data with file system attribute only in case of + // when preserve flag is passed. + if opts.Preserve { + fileAttr, err := disk.GetFileSystemAttrs(path) + if err != nil { + return nil, content, nil + } + metaData, pErr := getAllXattrs(path) + if pErr != nil { + return nil, content, nil + } + for k, v := range metaData { + content.Metadata[k] = v + } + content.Metadata[metadataKey] = fileAttr + } + + return fileData, content, nil } // Check if the given error corresponds to ENOTEMPTY for unix diff --git a/cmd/client-fs_test.go b/cmd/client-fs_test.go index 8e5f9164..10158820 100644 --- a/cmd/client-fs_test.go +++ b/cmd/client-fs_test.go @@ -290,7 +290,7 @@ func (s *TestSuite) TestGet(c *checkv1.C) { c.Assert(err, checkv1.IsNil) c.Assert(n, checkv1.Equals, int64(len(data))) - reader, err = fsClient.Get(context.Background(), GetOptions{}) + reader, _, err = fsClient.Get(context.Background(), GetOptions{}) c.Assert(err, checkv1.IsNil) var results bytes.Buffer _, e = io.Copy(&results, reader) @@ -319,7 +319,7 @@ func (s *TestSuite) TestGetRange(c *checkv1.C) { c.Assert(err, checkv1.IsNil) c.Assert(n, checkv1.Equals, int64(len(data))) - reader, err = fsClient.Get(context.Background(), GetOptions{}) + reader, _, err = fsClient.Get(context.Background(), GetOptions{}) c.Assert(err, checkv1.IsNil) var results bytes.Buffer buf := make([]byte, 5) diff --git a/cmd/client-s3.go b/cmd/client-s3.go index b66fe6b6..ad6a51c3 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -942,7 +942,7 @@ func (c *S3Client) Watch(ctx context.Context, options WatchOptions) (*WatchObjec } // Get - get object with GET options. -func (c *S3Client) Get(ctx context.Context, opts GetOptions) (io.ReadCloser, *probe.Error) { +func (c *S3Client) Get(ctx context.Context, opts GetOptions) (io.ReadCloser, *ClientContent, *probe.Error) { bucket, object := c.url2BucketAndObject() o := minio.GetObjectOptions{ ServerSideEncryption: opts.SSE, @@ -954,7 +954,7 @@ func (c *S3Client) Get(ctx context.Context, opts GetOptions) (io.ReadCloser, *pr if opts.RangeStart != 0 { err := o.SetRange(opts.RangeStart, 0) if err != nil { - return nil, probe.NewError(err) + return nil, nil, probe.NewError(err) } } // Disallow automatic decompression for some objects with content-encoding set. @@ -964,21 +964,39 @@ func (c *S3Client) Get(ctx context.Context, opts GetOptions) (io.ReadCloser, *pr if e != nil { errResponse := minio.ToErrorResponse(e) if errResponse.Code == "NoSuchBucket" { - return nil, probe.NewError(BucketDoesNotExist{ + return nil, nil, probe.NewError(BucketDoesNotExist{ Bucket: bucket, }) } if errResponse.Code == "InvalidBucketName" { - return nil, probe.NewError(BucketInvalid{ + return nil, nil, probe.NewError(BucketInvalid{ Bucket: bucket, }) } if errResponse.Code == "NoSuchKey" { - return nil, probe.NewError(ObjectMissing{}) + return nil, nil, probe.NewError(ObjectMissing{}) } - return nil, probe.NewError(e) + return nil, nil, probe.NewError(e) } - return reader, nil + objStat, e := reader.Stat() + if e != nil { + errResponse := minio.ToErrorResponse(e) + if errResponse.Code == "NoSuchBucket" { + return nil, nil, probe.NewError(BucketDoesNotExist{ + Bucket: bucket, + }) + } + if errResponse.Code == "InvalidBucketName" { + return nil, nil, probe.NewError(BucketInvalid{ + Bucket: bucket, + }) + } + if errResponse.Code == "NoSuchKey" { + return nil, nil, probe.NewError(ObjectMissing{}) + } + return nil, nil, probe.NewError(e) + } + return reader, c.objectInfo2ClientContent(bucket, objStat), nil } // Copy - copy object, uses server side copy API. Also uses an abstracted API diff --git a/cmd/client-s3_test.go b/cmd/client-s3_test.go index 9ff7da15..d9b3935c 100644 --- a/cmd/client-s3_test.go +++ b/cmd/client-s3_test.go @@ -265,7 +265,7 @@ func (s *TestSuite) TestObjectOperations(c *checkv1.C) { c.Assert(err, checkv1.IsNil) c.Assert(n, checkv1.Equals, int64(len(object.data))) - reader, err = s3c.Get(context.Background(), GetOptions{}) + reader, _, err = s3c.Get(context.Background(), GetOptions{}) c.Assert(err, checkv1.IsNil) var buffer bytes.Buffer { diff --git a/cmd/client.go b/cmd/client.go index 5d7d1598..3f8cf5b8 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -49,6 +49,7 @@ type GetOptions struct { VersionID string Zip bool RangeStart int64 + Preserve bool } // PutOptions holds options for PUT operation @@ -131,7 +132,7 @@ type Client interface { Select(ctx context.Context, expression string, sse encrypt.ServerSide, opts SelectObjectOpts) (io.ReadCloser, *probe.Error) // I/O operations with metadata. - Get(ctx context.Context, opts GetOptions) (reader io.ReadCloser, err *probe.Error) + Get(ctx context.Context, opts GetOptions) (reader io.ReadCloser, content *ClientContent, err *probe.Error) Put(ctx context.Context, reader io.Reader, size int64, progress io.Reader, opts PutOptions) (n int64, err *probe.Error) // Object Locking related API diff --git a/cmd/common-methods.go b/cmd/common-methods.go index 2f1cd25e..ea7feb6c 100644 --- a/cmd/common-methods.go +++ b/cmd/common-methods.go @@ -31,7 +31,6 @@ import ( "time" "golang.org/x/net/http/httpguts" - "gopkg.in/h2non/filetype.v1" "github.com/dustin/go-humanize" "github.com/minio/cli" @@ -142,7 +141,7 @@ func isAliasURLDir(ctx context.Context, aliasURL string, keys map[string][]prefi // getSourceStreamMetadataFromURL gets a reader from URL. func getSourceStreamMetadataFromURL(ctx context.Context, aliasedURL, versionID string, timeRef time.Time, encKeyDB map[string][]prefixSSEPair, zip bool) (reader io.ReadCloser, - metadata map[string]string, err *probe.Error, + content *ClientContent, err *probe.Error, ) { alias, urlStrFull, _, err := expandAlias(aliasedURL) if err != nil { @@ -166,8 +165,7 @@ func getSourceStreamMetadataFromURL(ctx context.Context, aliasedURL, versionID s type getSourceOpts struct { GetOptions - fetchStat bool - preserve bool + preserve bool } // getSourceStreamFromURL gets a reader from URL. @@ -181,30 +179,6 @@ func getSourceStreamFromURL(ctx context.Context, urlStr string, encKeyDB map[str return reader, err } -func probeContentType(reader io.Reader) (ctype string, err *probe.Error) { - ctype = "application/octet-stream" - // Read a chunk to decide between utf-8 text and binary - if s, ok := reader.(io.Seeker); ok { - var buf [512]byte - n, _ := io.ReadFull(reader, buf[:]) - if n <= 0 { - return ctype, nil - } - kind, e := filetype.Match(buf[:n]) - if e != nil { - return ctype, probe.NewError(e) - } - // rewind to output whole file - if _, e = s.Seek(0, io.SeekStart); e != nil { - return ctype, probe.NewError(e) - } - if kind.MIME.Value != "" { - ctype = kind.MIME.Value - } - } - return ctype, nil -} - // Verify if reader is a generic ReaderAt func isReadAt(reader io.Reader) (ok bool) { var v *os.File @@ -229,63 +203,18 @@ func isReadAt(reader io.Reader) (ok bool) { } // getSourceStream gets a reader from URL. -func getSourceStream(ctx context.Context, alias, urlStr string, opts getSourceOpts) (reader io.ReadCloser, metadata map[string]string, err *probe.Error) { +func getSourceStream(ctx context.Context, alias, urlStr string, opts getSourceOpts) (reader io.ReadCloser, content *ClientContent, err *probe.Error) { sourceClnt, err := newClientFromAlias(alias, urlStr) if err != nil { return nil, nil, err.Trace(alias, urlStr) } - reader, err = sourceClnt.Get(ctx, opts.GetOptions) + + reader, content, err = sourceClnt.Get(ctx, opts.GetOptions) if err != nil { return nil, nil, err.Trace(alias, urlStr) } - metadata = make(map[string]string) - if opts.fetchStat { - var st *ClientContent - mo, mok := reader.(*minio.Object) - if mok { - oinfo, e := mo.Stat() - if e != nil { - return nil, nil, probe.NewError(e).Trace(alias, urlStr) - } - st = &ClientContent{} - st.Time = oinfo.LastModified - st.Size = oinfo.Size - st.ETag = oinfo.ETag - st.Expires = oinfo.Expires - st.Type = os.FileMode(0o664) - st.Metadata = map[string]string{} - for k := range oinfo.Metadata { - st.Metadata[k] = oinfo.Metadata.Get(k) - } - st.ETag = oinfo.ETag - } else { - st, err = sourceClnt.Stat(ctx, StatOptions{preserve: opts.preserve, sse: opts.SSE}) - if err != nil { - return nil, nil, err.Trace(alias, urlStr) - } - } - - for k, v := range st.Metadata { - if httpguts.ValidHeaderFieldName(k) && - httpguts.ValidHeaderFieldValue(v) { - metadata[k] = v - } - } - - // All unrecognized files have `application/octet-stream` - // So we continue our detection process. - if ctype := metadata["Content-Type"]; ctype == "application/octet-stream" { - // Continue probing content-type if its filesystem stream. - if !mok { - metadata["Content-Type"], err = probeContentType(reader) - if err != nil { - return nil, nil, err.Trace(alias, urlStr) - } - } - } - } - return reader, metadata, nil + return reader, content, nil } // putTargetRetention sets retention headers if any @@ -544,22 +473,37 @@ func uploadSourceToTargetURL(ctx context.Context, uploadOpts uploadSourceToTarge return uploadOpts.urls.WithError(err.Trace(sourceURL.String())) } - var reader io.ReadCloser // Proceed with regular stream copy. - reader, metadata, err = getSourceStream(ctx, sourceAlias, sourceURL.String(), getSourceOpts{ + var ( + content *ClientContent + reader io.ReadCloser + ) + + reader, content, err = getSourceStream(ctx, sourceAlias, sourceURL.String(), getSourceOpts{ GetOptions: GetOptions{ VersionID: sourceVersion, SSE: srcSSE, Zip: uploadOpts.isZip, + Preserve: uploadOpts.preserve, }, - fetchStat: !uploadOpts.ignoreStat, - preserve: uploadOpts.preserve, }) if err != nil { return uploadOpts.urls.WithError(err.Trace(sourceURL.String())) } defer reader.Close() + if uploadOpts.updateProgressTotal { + pg, ok := uploadOpts.progress.(*progressBar) + if ok { + pg.SetTotal(content.Size) + } + } + + metadata := make(map[string]string, len(content.Metadata)) + for k, v := range content.Metadata { + metadata[k] = v + } + // Get metadata from target content as well for k, v := range uploadOpts.urls.TargetContent.Metadata { metadata[http.CanonicalHeaderKey(k)] = v @@ -679,11 +623,11 @@ func ParseForm(r *http.Request) error { } type uploadSourceToTargetURLOpts struct { - urls URLs - progress io.Reader - encKeyDB map[string][]prefixSSEPair - preserve, isZip bool - multipartSize string - multipartThreads string - ignoreStat bool + urls URLs + progress io.Reader + encKeyDB map[string][]prefixSSEPair + preserve, isZip bool + multipartSize string + multipartThreads string + updateProgressTotal bool } diff --git a/cmd/cp-main.go b/cmd/cp-main.go index c2c4fd96..5648ed4b 100644 --- a/cmd/cp-main.go +++ b/cmd/cp-main.go @@ -266,7 +266,16 @@ func doCopy(ctx context.Context, copyOpts doCopyOpts) URLs { }) } - urls := uploadSourceToTargetURL(ctx, uploadSourceToTargetURLOpts{urls: copyOpts.cpURLs, progress: copyOpts.pg, encKeyDB: copyOpts.encKeyDB, preserve: copyOpts.preserve, isZip: copyOpts.isZip, multipartSize: copyOpts.multipartSize, multipartThreads: copyOpts.multipartThreads, ignoreStat: copyOpts.ignoreStat}) + urls := uploadSourceToTargetURL(ctx, uploadSourceToTargetURLOpts{ + urls: copyOpts.cpURLs, + progress: copyOpts.pg, + encKeyDB: copyOpts.encKeyDB, + preserve: copyOpts.preserve, + isZip: copyOpts.isZip, + multipartSize: copyOpts.multipartSize, + multipartThreads: copyOpts.multipartThreads, + updateProgressTotal: copyOpts.updateProgressTotal, + }) if copyOpts.isMvCmd && urls.Error == nil { rmManager.add(ctx, sourceAlias, sourceURL.String()) } @@ -562,7 +571,14 @@ func doCopySession(ctx context.Context, cancelCopy context.CancelFunc, cli *cli. startContinue = false } parallel.queueTask(func() URLs { - return doCopy(ctx, doCopyOpts{cpURLs: cpURLs, pg: pg, encKeyDB: encKeyDB, isMvCmd: isMvCmd, preserve: preserve, isZip: isZip}) + return doCopy(ctx, doCopyOpts{ + cpURLs: cpURLs, + pg: pg, + encKeyDB: encKeyDB, + isMvCmd: isMvCmd, + preserve: preserve, + isZip: isZip, + }) }, cpURLs.SourceContent.Size) } } @@ -764,7 +780,7 @@ type doCopyOpts struct { pg ProgressReader encKeyDB map[string][]prefixSSEPair isMvCmd, preserve, isZip bool + updateProgressTotal bool multipartSize string multipartThreads string - ignoreStat bool } diff --git a/cmd/get-main.go b/cmd/get-main.go index 304a6ee3..da3ffae4 100644 --- a/cmd/get-main.go +++ b/cmd/get-main.go @@ -66,9 +66,10 @@ func mainGet(cliCtx *cli.Context) (e error) { fatalIf(err, "Unable to parse encryption keys.") args := cliCtx.Args() - if len(args) < 2 { + if len(args) != 2 { showCommandHelpAndExit(cliCtx, 1) // last argument is exit code. } + // get source and target sourceURLs := args[:len(args)-1] targetURL := args[len(args)-1] @@ -97,8 +98,6 @@ func mainGet(cliCtx *cli.Context) (e error) { getURLsCh <- getURLs break } - totalBytes += getURLs.SourceContent.Size - pg.SetTotal(totalBytes) totalObjects++ getURLsCh <- getURLs } @@ -119,7 +118,12 @@ func mainGet(cliCtx *cli.Context) (e error) { showLastProgressBar(pg, getURLs.Error.ToGoError()) return } - urls := doCopy(ctx, doCopyOpts{cpURLs: getURLs, pg: pg, encKeyDB: encKeyDB, isMvCmd: false, preserve: false, isZip: false, ignoreStat: true}) + urls := doCopy(ctx, doCopyOpts{ + cpURLs: getURLs, + pg: pg, + encKeyDB: encKeyDB, + updateProgressTotal: true, + }) if urls.Error != nil { e = urls.Error.ToGoError() showLastProgressBar(pg, e) diff --git a/cmd/head-main.go b/cmd/head-main.go index eefe1c64..5a20434b 100644 --- a/cmd/head-main.go +++ b/cmd/head-main.go @@ -99,11 +99,12 @@ func headURL(sourceURL, sourceVersion string, timeRef time.Time, encKeyDB map[st reader = os.Stdin default: var err *probe.Error - var metadata map[string]string - if reader, metadata, err = getSourceStreamMetadataFromURL(context.Background(), sourceURL, sourceVersion, timeRef, encKeyDB, zip); err != nil { + var content *ClientContent + if reader, content, err = getSourceStreamMetadataFromURL(context.Background(), sourceURL, sourceVersion, timeRef, encKeyDB, zip); err != nil { return err.Trace(sourceURL) } - ctype := metadata["Content-Type"] + + ctype := content.Metadata["Content-Type"] if strings.Contains(ctype, "gzip") { var e error reader, e = gzip.NewReader(reader) diff --git a/cmd/progress-bar.go b/cmd/progress-bar.go index c2c282b1..d7ca7ef3 100644 --- a/cmd/progress-bar.go +++ b/cmd/progress-bar.go @@ -35,7 +35,7 @@ type progressBar struct { func newPB(total int64) *pb.ProgressBar { // Progress bar specific theme customization. - console.SetColor("Bar", color.New(color.FgYellow, color.Bold)) + console.SetColor("Bar", color.New(color.FgGreen, color.Bold)) // get the new original progress bar. bar := pb.New64(total) @@ -59,18 +59,19 @@ func newPB(total int64) *pb.ProgressBar { // Use different unicodes for Linux, OS X and Windows. switch runtime.GOOS { - case "linux", "darwin": + case "linux": // Need to add '\x00' as delimiter for unicode characters. - bar.Format("━\x00━\x00━\x00┉\x00━") + bar.Format("┃\x00▓\x00█\x00░\x00┃") + case "darwin": + // Need to add '\x00' as delimiter for unicode characters. + bar.Format(" \x00▓\x00 \x00░\x00 ") default: // Default to non unicode characters. bar.Format("[=> ]") } // Start the progress bar. - bar.Start() - - return bar + return bar.Start() } func newProgressReader(r io.Reader, caption string, total int64) *pb.Reader { @@ -99,7 +100,6 @@ func (p *progressBar) SetCaption(caption string) *progressBar { } func (p *progressBar) Finish() { - console.SetColor("Bar", color.New(color.FgGreen, color.Bold)) p.ProgressBar.Finish() } diff --git a/cmd/put-main.go b/cmd/put-main.go index 7863fa90..61bae29f 100644 --- a/cmd/put-main.go +++ b/cmd/put-main.go @@ -156,7 +156,13 @@ func mainPut(cliCtx *cli.Context) (e error) { showLastProgressBar(pg, putURLs.Error.ToGoError()) return } - urls := doCopy(ctx, doCopyOpts{cpURLs: putURLs, pg: pg, encKeyDB: encKeyDB, isMvCmd: false, preserve: false, isZip: false, multipartSize: size, multipartThreads: strconv.Itoa(threads)}) + urls := doCopy(ctx, doCopyOpts{ + cpURLs: putURLs, + pg: pg, + encKeyDB: encKeyDB, + multipartSize: size, + multipartThreads: strconv.Itoa(threads), + }) if urls.Error != nil { e = urls.Error.ToGoError() showLastProgressBar(pg, e) diff --git a/cmd/sql-main.go b/cmd/sql-main.go index d86ba649..b9d511c1 100644 --- a/cmd/sql-main.go +++ b/cmd/sql-main.go @@ -308,11 +308,12 @@ func getCSVHeader(sourceURL string, encKeyDB map[string][]prefixSSEPair) ([]stri r = os.Stdin default: var err *probe.Error - var metadata map[string]string - if r, metadata, err = getSourceStreamMetadataFromURL(globalContext, sourceURL, "", time.Time{}, encKeyDB, false); err != nil { + var content *ClientContent + if r, content, err = getSourceStreamMetadataFromURL(globalContext, sourceURL, "", time.Time{}, encKeyDB, false); err != nil { return nil, err.Trace(sourceURL) } - ctype := metadata["Content-Type"] + + ctype := content.Metadata["Content-Type"] if strings.Contains(ctype, "gzip") { var e error r, e = gzip.NewReader(r)