Don't add data_descripters when merging uncompress zip entries for merge_zips.
Also filter out META-INF/TRANSITIVE dir, and report warnings when merge_zips see duplicates entries with different CRC hash. Bug: b/65455145 Test: m clean && m -j java (locally) Change-Id: I47172ffa27df71f3280f35f6b540a7b5a0c14550
This commit is contained in:
37
third_party/zip/android.go
vendored
37
third_party/zip/android.go
vendored
@@ -32,7 +32,6 @@ func (w *Writer) CopyFrom(orig *File, newName string) error {
|
||||
fileHeader := orig.FileHeader
|
||||
fileHeader.Name = newName
|
||||
fh := &fileHeader
|
||||
fh.Flags |= DataDescriptorFlag
|
||||
|
||||
// The zip64 extras change between the Central Directory and Local File Header, while we use
|
||||
// the same structure for both. The Local File Haeder is taken care of by us writing a data
|
||||
@@ -57,24 +56,26 @@ func (w *Writer) CopyFrom(orig *File, newName string) error {
|
||||
}
|
||||
io.Copy(w.cw, io.NewSectionReader(orig.zipr, dataOffset, int64(orig.CompressedSize64)))
|
||||
|
||||
// Write data descriptor.
|
||||
var buf []byte
|
||||
if fh.isZip64() {
|
||||
buf = make([]byte, dataDescriptor64Len)
|
||||
} else {
|
||||
buf = make([]byte, dataDescriptorLen)
|
||||
if orig.hasDataDescriptor() {
|
||||
// Write data descriptor.
|
||||
var buf []byte
|
||||
if fh.isZip64() {
|
||||
buf = make([]byte, dataDescriptor64Len)
|
||||
} else {
|
||||
buf = make([]byte, dataDescriptorLen)
|
||||
}
|
||||
b := writeBuf(buf)
|
||||
b.uint32(dataDescriptorSignature)
|
||||
b.uint32(fh.CRC32)
|
||||
if fh.isZip64() {
|
||||
b.uint64(fh.CompressedSize64)
|
||||
b.uint64(fh.UncompressedSize64)
|
||||
} else {
|
||||
b.uint32(fh.CompressedSize)
|
||||
b.uint32(fh.UncompressedSize)
|
||||
}
|
||||
_, err = w.cw.Write(buf)
|
||||
}
|
||||
b := writeBuf(buf)
|
||||
b.uint32(dataDescriptorSignature)
|
||||
b.uint32(fh.CRC32)
|
||||
if fh.isZip64() {
|
||||
b.uint64(fh.CompressedSize64)
|
||||
b.uint64(fh.UncompressedSize64)
|
||||
} else {
|
||||
b.uint32(fh.CompressedSize)
|
||||
b.uint32(fh.UncompressedSize)
|
||||
}
|
||||
_, err = w.cw.Write(buf)
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user