Skip to content

Commit

Permalink
removed forced removal of temp files with an os.remove
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Clifford committed Jul 29, 2022
1 parent 14e59cd commit 5126a05
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ endif
.PHONY: clean
clean:
$(GOCLEAN)
rm -rf dist/
rm -rf builds/
rm -r dist/
rm -r builds/

deps:
${GOCMD} get -v
Expand Down
11 changes: 6 additions & 5 deletions cmd/selfUpdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,14 @@ func getChecksum(url string) ([]byte, error) {
}

func cleanUpSelfUpdate(signatureFile string, checksumFile string) error {
execString := fmt.Sprintf("rm -rf %s %s", signatureFile, checksumFile)
fmt.Printf("\x1b[37mCleanup checksum files with: %s\x1b[0m\n", execString)
fmt.Printf("\x1b[37mCleanup signature and checksum files\x1b[0m\n")
files := []string{signatureFile, checksumFile}

if !dryRun {
err, _, errstring := utils.Shellout(execString)
if err != nil {
utils.LogFatalError(errstring, nil)
for _, f := range files {
if err := os.Remove(f); err != nil {
utils.LogFatalError(err.Error(), nil)
}
}
}

Expand Down
21 changes: 9 additions & 12 deletions synchers/prerequisiteSyncUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package synchers
import (
"encoding/json"
"fmt"
"github.com/uselagoon/lagoon-sync/assets"
"io/ioutil"
"log"
"os"
"strings"

"github.com/uselagoon/lagoon-sync/assets"

"github.com/uselagoon/lagoon-sync/prerequisite"
"github.com/uselagoon/lagoon-sync/utils"
)
Expand Down Expand Up @@ -177,11 +179,9 @@ func createRsync(environment Environment, syncer Syncer, lagoonSyncVersion strin
}

// Remove local versioned rsync (post ssh transfer) - otherwise rsync will be avialable on target at /tmp/
removeLocalRsyncCopyExecString := fmt.Sprintf("rm -rf %v", rsyncDestinationPath)
log.Printf("Removing rsync binary locally stored: %v", removeLocalRsyncCopyExecString)
if err, _, errstring := utils.Shellout(removeLocalRsyncCopyExecString); err != nil {
log.Println(errstring)
return "", err
log.Printf("Removing rsync binary locally stored: %s", rsyncDestinationPath)
if err := os.Remove(rsyncDestinationPath); err != nil {
log.Println(err.Error())
}

return rsyncDestinationPath, nil
Expand Down Expand Up @@ -210,12 +210,9 @@ func createRsyncAssetFromBytes(lagoonSyncVersion string) (string, error) {
return "", err
}

removeTempLocalRsyncCopyExecString := fmt.Sprintf("rm -rf %v", tempRsyncPath)
utils.LogExecutionStep("Removing temp rsync binary", removeTempLocalRsyncCopyExecString)

if err, _, errstring := utils.Shellout(removeTempLocalRsyncCopyExecString); err != nil {
log.Println(errstring)
return "", err
log.Printf("Removing temp rsync binary: %s", tempRsyncPath)
if err := os.Remove(tempRsyncPath); err != nil {
log.Println(err.Error())
}

return versionedRsyncPath, nil
Expand Down

0 comments on commit 5126a05

Please sign in to comment.