Skip to content

Commit d6321df

Browse files
committed
Fix: Don't fail on directories
1 parent 7026f3c commit d6321df

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ func GetUploadFilename(file io.Reader, filename string, skipVersioning bool) (st
160160
return uploadFilename, nil
161161
}
162162

163+
func IsDirectory(path string) (bool, error) {
164+
info, err := os.Stat(path)
165+
if err != nil {
166+
return false, err
167+
}
168+
return info.IsDir(), err
169+
}
170+
163171
// VersionAndUploadFiles will verion files and upload them to s3 and return
164172
// a map of filenames and their version hashes
165173
func VersionAndUploadFiles(
@@ -174,6 +182,10 @@ func VersionAndUploadFiles(
174182
fmt.Printf("Uploading to %s/%s\n", bucket, directory)
175183

176184
for _, filename := range filenames {
185+
isDir, err := IsDirectory(filename)
186+
if isDir || err != nil {
187+
continue
188+
}
177189
file, err := os.Open(filename)
178190
if err != nil {
179191
return fileVersions, err

0 commit comments

Comments
 (0)