Skip to content

Commit

Permalink
fix(cdsctl,worker): artifact download os.O_TRUNC (#4311)
Browse files Browse the repository at this point in the history
  • Loading branch information
yesnault authored and richardlt committed May 21, 2019
1 parent fa92990 commit c8eaa48
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/cdsctl/workflow_artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func workflowArtifactDownloadRun(v cli.Values) error {

if toDownload {
var errf error
f, errf = os.OpenFile(a.Name, os.O_RDWR|os.O_CREATE, os.FileMode(a.Perm))
f, errf = os.OpenFile(a.Name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, os.FileMode(a.Perm))
if errf != nil {
return errf
}
Expand Down
2 changes: 1 addition & 1 deletion engine/worker/builtin_artifact_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func runArtifactDownload(w *currentWorker) BuiltInAction {
defer wg.Done()

destFile := path.Join(destPath, a.Name)
f, err := os.OpenFile(destFile, os.O_RDWR|os.O_CREATE, os.FileMode(a.Perm))
f, err := os.OpenFile(destFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, os.FileMode(a.Perm))
if err != nil {
res.Status = sdk.StatusFail.String()
res.Reason = err.Error()
Expand Down
2 changes: 1 addition & 1 deletion engine/worker/cmd_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (wk *currentWorker) downloadHandler(w http.ResponseWriter, r *http.Request)
defer wg.Done()

path := path.Join(reqArgs.Destination, a.Name)
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, os.FileMode(a.Perm))
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, os.FileMode(a.Perm))
if err != nil {
sendLog(fmt.Sprintf("Cannot download artifact (OpenFile) %s: %s", a.Name, err))
isInError = true
Expand Down

0 comments on commit c8eaa48

Please sign in to comment.