Skip to content
Open
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
18 changes: 6 additions & 12 deletions pkg/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"
"log"
"os/exec"
"os"
"time"

"github.com/app-sre/git-partition-sync-consumer/pkg/metrics"
Expand Down Expand Up @@ -43,8 +43,7 @@ func NewDownloader(
workdir string,
runOnce bool) (*Downloader, error) {

cmd := exec.Command("mkdir", "-p", workdir)
err := cmd.Run()
err := os.Mkdir(workdir, 0755)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -148,15 +147,12 @@ func (d *Downloader) Run(ctx context.Context, dryRun, runOnce bool) error {

// clean target working directory
func (d *Downloader) clean(directory string) error {
cmd := exec.Command("rm", "-rf", directory)
cmd.Dir = d.workdir
err := cmd.Run()
err := os.RemoveAll(directory)
if err != nil {
return err
}
cmd = exec.Command("mkdir", directory)
cmd.Dir = d.workdir
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same filepath change needed here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err = cmd.Run()

err = os.Mkdir(directory, 0775)
if err != nil {
return err
}
Expand All @@ -165,9 +161,7 @@ func (d *Downloader) clean(directory string) error {

// clear all items in working directory
func (d *Downloader) clear() error {
cmd := exec.Command("rm", "-rf", UNTAR_DIRECTORY)
cmd.Dir = d.workdir
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filepath change

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err := cmd.Run()
err := os.RemoveAll(UNTAR_DIRECTORY)
if err != nil {
return err
}
Expand Down