Skip to content

Commit 7149581

Browse files
authored
moved file.close() to the end of the loop as opposed to deferring the call. This is because deferring the call would close all the files after the function scope is finished which results in an accumelated number of open files. This causes the utility to crash when too many files are being uploaded all at once. (#22)
Co-authored-by: Peter Emil <[email protected]>
1 parent ada7ec8 commit 7149581

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
)
2727

2828
// VERSION is the current version
29-
const VERSION = "0.2.1"
29+
const VERSION = "0.4.0"
3030

3131
var defaultS3Bucket = "static.buffer.com"
3232
var uploader *s3manager.Uploader
@@ -190,7 +190,6 @@ func VersionAndUploadFiles(
190190
if err != nil {
191191
return fileVersions, err
192192
}
193-
defer file.Close()
194193

195194
uploadFilename, err := GetUploadFilename(file, filename, skipVersioning)
196195
if err != nil {
@@ -214,6 +213,7 @@ func VersionAndUploadFiles(
214213
}
215214

216215
fileVersions[filename] = fileURL
216+
file.Close()
217217
}
218218

219219
return fileVersions, nil

0 commit comments

Comments
 (0)