Skip to content

Fix agent not able to install esptool after 1.6.0 #986

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

Merged
merged 6 commits into from
Aug 5, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
implement properly rename function to fix extraction issue with esptool
  • Loading branch information
umbynos committed Aug 5, 2024
commit 0593ee0baa2d4639c665e2531174fa7c70af6043
14 changes: 9 additions & 5 deletions v2/pkgs/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,19 @@ func (t *Tools) Remove(ctx context.Context, payload *tools.ToolPayload) (*tools.
return &tools.Operation{Status: "ok"}, nil
}

// rename function is used to rename the path of the extracted files
func rename(base string) extract.Renamer {
// "Rename" the given path adding the "base" and removing the root folder in "path" (if present).
return func(path string) string {
parts := strings.Split(filepath.ToSlash(path), "/")
newPath := strings.Join(parts[1:], "/")
if newPath == "" {
newPath = filepath.Join(newPath, path)
if len(parts) <= 1 {
// The path does not contain a root folder. This might happen for tool packages (zip files)
// that have an invalid structure. Do not try to remove the root folder in these cases.
return filepath.Join(base, path)
}
path = filepath.Join(base, newPath)
return path
// Removes the first part of the path (the root folder).
path = strings.Join(parts[1:], "/")
return filepath.Join(base, path)
}
}

Expand Down
Loading