From 796cca416652ff1d49f186ec8110be6459fc514b Mon Sep 17 00:00:00 2001 From: ebozduman Date: Mon, 6 Jan 2020 12:43:00 -0800 Subject: [PATCH] Creates zipped files with correct mod times for objects (#8693) --- cmd/web-handlers.go | 8 +++++--- go.mod | 4 ++-- go.sum | 9 ++++++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cmd/web-handlers.go b/cmd/web-handlers.go index 6cc5f172d..f26778b40 100644 --- a/cmd/web-handlers.go +++ b/cmd/web-handlers.go @@ -542,7 +542,7 @@ func (web *webAPIHandlers) ListObjects(r *http.Request, args *ListObjectsArgs, r return toJSONError(ctx, err) } } else if lo.Objects[i].IsCompressed() { - var actualSize int64 = lo.Objects[i].GetActualSize() + actualSize := lo.Objects[i].GetActualSize() if actualSize < 0 { return toJSONError(ctx, errInvalidDecompressedSize) } @@ -1401,8 +1401,10 @@ func (web *webAPIHandlers) DownloadZip(w http.ResponseWriter, r *http.Request) { info.Size = info.GetActualSize() } header := &zip.FileHeader{ - Name: strings.TrimPrefix(objectName, args.Prefix), - Method: zip.Deflate, + Name: strings.TrimPrefix(objectName, args.Prefix), + Method: zip.Deflate, + Flags: 1 << 11, + Modified: info.ModTime, } if hasStringSuffixInSlice(info.Name, standardExcludeCompressExtensions) || hasPattern(standardExcludeCompressContentTypes, info.ContentType) { // We strictly disable compression for standard extensions/content-types. diff --git a/go.mod b/go.mod index fa7a69e01..8853a1011 100644 --- a/go.mod +++ b/go.mod @@ -50,8 +50,8 @@ require ( github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf github.com/jonboulle/clockwork v0.1.0 // indirect github.com/json-iterator/go v1.1.7 - github.com/klauspost/compress v1.9.4 - github.com/klauspost/cpuid v1.2.1 // indirect + github.com/klauspost/compress v1.9.7 + github.com/klauspost/cpuid v1.2.2 // indirect github.com/klauspost/pgzip v1.2.1 github.com/klauspost/readahead v1.3.1 github.com/klauspost/reedsolomon v1.9.3 diff --git a/go.sum b/go.sum index 076903dbb..5996838b4 100644 --- a/go.sum +++ b/go.sum @@ -219,10 +219,17 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.9.4 h1:xhvAeUPQ2drNUhKtrGdTGNvV9nNafHMUkRyLkzxJoB4= +github.com/klauspost/compress v1.8.3 h1:CkLseiEYMM/fRb0RIg9mXB+Iwgmle+U9KGFu+JCO4Ec= +github.com/klauspost/compress v1.8.3/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.9.4/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.9.7 h1:hYW1gP94JUmAhBtJ+LNz5My+gBobDxPR1iVuKug26aA= +github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/cpuid v0.0.0-20160106104451-349c67577817/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= +github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= +github.com/klauspost/cpuid v1.2.2 h1:1xAgYebNnsb9LKCdLOvFWtAxGU/33mjJtyOVbmUa0Us= +github.com/klauspost/cpuid v1.2.2/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/pgzip v1.2.1 h1:oIPZROsWuPHpOdMVWLuJZXwgjhrW8r1yEX8UqMyeNHM= github.com/klauspost/pgzip v1.2.1/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/klauspost/readahead v1.3.1 h1:QqXNYvm+VvqYcbrRT4LojUciM0XrznFRIDrbHiJtu/0=