Skip to content

Clean up temporary files on exit #159

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 2 commits into from
Jan 10, 2023
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
2 changes: 1 addition & 1 deletion indexes/download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func DownloadIndex(indexURL string) (*paths.Path, error) {
if err != nil {
return nil, err
}
defer tempDir.Remove()
defer tempDir.RemoveAll()

// Download index
tmpGZIndex := tempDir.Join("index.gz")
Expand Down
1 change: 1 addition & 0 deletions indexes/indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func GetPackageIndex() (*packageindex.Index, error) {

// GetFirmwareIndex downloads and loads the arduino-fwuploader module_firmware_index.json
func GetFirmwareIndex() (*firmwareindex.Index, error) {
defer globals.FwUploaderPath.RemoveAll()
indexPath, err := download.DownloadIndex(globals.ModuleFirmwareIndexGZURL)
if err != nil {
logrus.Error(err)
Expand Down
2 changes: 2 additions & 0 deletions indexes/indexes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"testing"

"github.com/arduino/arduino-cli/arduino/cores/packageindex"
"github.com/arduino/arduino-fwuploader/cli/globals"
"github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
)
Expand All @@ -47,4 +48,5 @@ func TestGetFirmwareIndex(t *testing.T) {
index, err := GetFirmwareIndex()
require.NoError(t, err)
require.NotNil(t, index)
require.NoDirExists(t, globals.FwUploaderPath.String())
}