Skip to content

Commit

Permalink
missing umask/mode and copy util calls
Browse files Browse the repository at this point in the history
  • Loading branch information
langmartin authored and shoenig committed May 28, 2020
1 parent 3c581d4 commit 142d79c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 31 deletions.
14 changes: 1 addition & 13 deletions get_file_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,7 @@ func (g *FileGetter) GetFile(dst string, u *url.URL) error {
}

// Copy
srcF, err := os.Open(path)
if err != nil {
return err
}
defer srcF.Close()

dstF, err := os.Create(dst)
if err != nil {
return err
}
defer dstF.Close()

_, err = Copy(ctx, dstF, srcF)
_, err = copyFile(ctx, dst, path, 0666, g.client.umask())
return err
}

Expand Down
13 changes: 3 additions & 10 deletions get_gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (g *GCSGetter) Get(dst string, u *url.URL) error {
}

// Create all the parent directories
if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
if err := os.MkdirAll(filepath.Dir(dst), g.client.mode(0755)); err != nil {
return err
}

Expand Down Expand Up @@ -138,18 +138,11 @@ func (g *GCSGetter) getObject(ctx context.Context, client *storage.Client, dst,
defer rc.Close()

// Create all the parent directories
if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
if err := os.MkdirAll(filepath.Dir(dst), g.client.mode(0755)); err != nil {
return err
}

f, err := os.Create(dst)
if err != nil {
return err
}
defer f.Close()

_, err = Copy(ctx, f, rc)
return err
return copyReader(dst, rc, 0666, g.client.umask())
}

func (g *GCSGetter) parseURL(u *url.URL) (bucket, path string, err error) {
Expand Down
9 changes: 1 addition & 8 deletions get_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,7 @@ func (g *S3Getter) getObject(ctx context.Context, client *s3.S3, dst, bucket, ke
return err
}

f, err := os.Create(dst)
if err != nil {
return err
}
defer f.Close()

_, err = Copy(ctx, f, resp.Body)
return err
return copyReader(dst, resp.Body, 0666, g.client.umask())
}

func (g *S3Getter) getAWSConfig(region string, url *url.URL, creds *credentials.Credentials) *aws.Config {
Expand Down

0 comments on commit 142d79c

Please sign in to comment.