Skip to content

Commit

Permalink
Remove Cleanup code to fix parallel use (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins authored Aug 1, 2023
1 parent 17c1339 commit faf6179
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 28 deletions.
2 changes: 0 additions & 2 deletions commands/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ var CompletionCmd = &cobra.Command{
if errors.As(err, &execErr) {
exitCode = execErr.ExitCode()
}
//nolint:errcheck
c.Cleanup()
os.Exit(exitCode)
return
}
Expand Down
4 changes: 0 additions & 4 deletions commands/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ var ListCmd = &cobra.Command{
if errors.As(err, &execErr) {
exitCode = execErr.ExitCode()
}
//nolint:errcheck
c.Cleanup()
os.Exit(exitCode)
return
}
Expand Down Expand Up @@ -101,8 +99,6 @@ var ListCmd = &cobra.Command{
if errors.As(err, &execErr) {
exitCode = execErr.ExitCode()
}
//nolint:errcheck
c.Cleanup()
os.Exit(exitCode)
}
return
Expand Down
2 changes: 0 additions & 2 deletions commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ var RootCmd = &cobra.Command{
if errors.As(err, &execErr) {
exitCode = execErr.ExitCode()
}
//nolint:errcheck
c.Cleanup()
os.Exit(exitCode)
}
},
Expand Down
20 changes: 0 additions & 20 deletions internal/legacy/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"os"
"os/exec"
"path"
"strings"

"github.com/gofrs/flock"
)
Expand Down Expand Up @@ -103,25 +102,6 @@ func (c *CLIWrapper) Init() error {
return nil
}

// Cleanup the CLI wrapper, removing the cache directory that was created and any other related directory
func (c *CLIWrapper) Cleanup() error {
files, err := os.ReadDir(os.TempDir())
if err != nil {
return fmt.Errorf("could not list temporary directory: %w", err)
}

for _, f := range files {
if strings.HasPrefix(f.Name(), prefix) {
err := os.RemoveAll(path.Join(os.TempDir(), f.Name()))
if err != nil && c.Debug {
c.debugLog("could not remove directory: %s", f.Name())
}
}
}

return nil
}

// Exec a legacy CLI command with the given arguments
func (c *CLIWrapper) Exec(ctx context.Context, args ...string) error {
args = append([]string{c.PSHPath()}, args...)
Expand Down

0 comments on commit faf6179

Please sign in to comment.