Merge "Don't attempt to deflate when compression level is 0"

am: 37dc2c26f0

Change-Id: I83e4e6d7e81d08bf7922edb72111c73be2c380b2
This commit is contained in:
Colin Cross 2018-09-17 14:28:48 -07:00 committed by android-build-merger
commit d546014474

View file

@ -220,14 +220,17 @@ func Run(args ZipArgs) (err error) {
} }
pathMappings := []pathMapping{} pathMappings := []pathMapping{}
noCompression := args.CompressionLevel == 0
for _, fa := range args.FileArgs { for _, fa := range args.FileArgs {
srcs := fa.SourceFiles srcs := fa.SourceFiles
if fa.GlobDir != "" { if fa.GlobDir != "" {
srcs = append(srcs, recursiveGlobFiles(fa.GlobDir)...) srcs = append(srcs, recursiveGlobFiles(fa.GlobDir)...)
} }
for _, src := range srcs { for _, src := range srcs {
if err := fillPathPairs(fa.PathPrefixInZip, err := fillPathPairs(fa.PathPrefixInZip, fa.SourcePrefixToStrip, src,
fa.SourcePrefixToStrip, src, &pathMappings, args.NonDeflatedFiles); err != nil { &pathMappings, args.NonDeflatedFiles, noCompression)
if err != nil {
log.Fatal(err) log.Fatal(err)
} }
} }
@ -267,7 +270,9 @@ func Run(args ZipArgs) (err error) {
return nil return nil
} }
func fillPathPairs(prefix, rel, src string, pathMappings *[]pathMapping, nonDeflatedFiles map[string]bool) error { func fillPathPairs(prefix, rel, src string, pathMappings *[]pathMapping,
nonDeflatedFiles map[string]bool, noCompression bool) error {
src = strings.TrimSpace(src) src = strings.TrimSpace(src)
if src == "" { if src == "" {
return nil return nil
@ -280,7 +285,7 @@ func fillPathPairs(prefix, rel, src string, pathMappings *[]pathMapping, nonDefl
dest = filepath.Join(prefix, dest) dest = filepath.Join(prefix, dest)
zipMethod := zip.Deflate zipMethod := zip.Deflate
if _, found := nonDeflatedFiles[dest]; found { if _, found := nonDeflatedFiles[dest]; found || noCompression {
zipMethod = zip.Store zipMethod = zip.Store
} }
*pathMappings = append(*pathMappings, *pathMappings = append(*pathMappings,