-
Notifications
You must be signed in to change notification settings - Fork 7
use os functions instead of running exec #34
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ import ( | |
| "context" | ||
| "fmt" | ||
| "log" | ||
| "os/exec" | ||
| "os" | ||
| "time" | ||
|
|
||
| "github.com/app-sre/git-partition-sync-consumer/pkg/metrics" | ||
|
|
@@ -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 | ||
| } | ||
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same filepath change needed here There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| } | ||
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. filepath change There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.