Extract zip archive with multiple entries (#4283)

* extract zip archive with multiple entries

Signed-off-by: Kudryavcev Nikolay <kydry.nikolau@gmail.com>

* set OverwriteExisting by type assertion switch case

Signed-off-by: Kudryavcev Nikolay <kydry.nikolau@gmail.com>

---------

Signed-off-by: Kudryavcev Nikolay <kydry.nikolau@gmail.com>
This commit is contained in:
Kudryavcev Nikolay 2025-10-15 19:05:05 +03:00 committed by GitHub
parent e9a8bc5ab9
commit 065ac13ab7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -231,11 +231,14 @@ func fileAnalysisPath(path string, skipExtractArchive bool) (string, func() erro
// unarchived. // unarchived.
envelopedUnarchiver, err := archiver.ByExtension(path) envelopedUnarchiver, err := archiver.ByExtension(path)
if unarchiver, ok := envelopedUnarchiver.(archiver.Unarchiver); err == nil && ok { if unarchiver, ok := envelopedUnarchiver.(archiver.Unarchiver); err == nil && ok {
if tar, ok := unarchiver.(*archiver.Tar); ok { // when tar/zip files are extracted, if there are multiple entries at the same
// when tar files are extracted, if there are multiple entries at the same
// location, the last entry wins // location, the last entry wins
// NOTE: this currently does not display any messages if an overwrite happens // NOTE: this currently does not display any messages if an overwrite happens
tar.OverwriteExisting = true switch v := unarchiver.(type) {
case *archiver.Tar:
v.OverwriteExisting = true
case *archiver.Zip:
v.OverwriteExisting = true
} }
analysisPath, cleanupFn, err = unarchiveToTmp(path, unarchiver) analysisPath, cleanupFn, err = unarchiveToTmp(path, unarchiver)