Skip to content

Commit

Permalink
Getter comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanuber committed Jan 5, 2017
1 parent e533954 commit f042e74
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions get_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func (g *FileGetter) ClientMode(u *url.URL) (ClientMode, error) {
path = u.RawPath
}

// Check if the source is a directory.
if fi, err := os.Stat(path); err == nil && fi.IsDir() {
return ClientModeDir, nil
}
Expand Down
5 changes: 3 additions & 2 deletions get_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ func (g *S3Getter) ClientMode(u *url.URL) (ClientMode, error) {
return 0, err
}

// Create client config
config := g.getAWSConfig(region, creds)
sess := session.New(config)
client := s3.New(sess)

// List the object(s) at the given prefix
req := &s3.ListObjectsInput{
Bucket: aws.String(bucket),
Prefix: aws.String(path),
}

resp, err := client.ListObjects(req)
if err != nil {
return 0, err
Expand All @@ -54,7 +55,7 @@ func (g *S3Getter) ClientMode(u *url.URL) (ClientMode, error) {
}

// There was no match, so just return file mode. The download is going
// to fail but we will let S3 return the proper error.
// to fail but we will let S3 return the proper error later.
return ClientModeFile, nil
}

Expand Down

0 comments on commit f042e74

Please sign in to comment.