Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #23456 to 7.x: Skip top level files when unziping archive during upgrade #23458

Merged
merged 2 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- Fix shell wrapper for deb/rpm packaging {pull}23038[23038]
- Fixed parsing of npipe URI {pull}22978[22978]
- Remove artifacts on transient download errors {pull}23235[23235]
- Skip top level files when unziping archive during upgrade {pull}23456[23456]
- Do not take ownership of Endpoint log path {pull}23444[23444]

==== New features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ func unzip(version, archivePath string) (string, error) {

for _, f := range r.File {
if rootDir == "" && filepath.Base(f.Name) == filepath.Dir(f.Name) {
return f.Name, nil
// skip top level files
continue
}
if currentDir := filepath.Dir(f.Name); rootDir == "" || len(currentDir) < len(rootDir) {
rootDir = currentDir
Expand Down