Skip to content

Commit

Permalink
fix(pgs): close any open readers
Browse files Browse the repository at this point in the history
  • Loading branch information
neurosnap committed Jan 26, 2025
1 parent 9410239 commit 894e7de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pgs/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ func (h *UploadAssetHandler) findDenylist(bucket sst.Bucket, project *db.Project
if err != nil {
return "", fmt.Errorf("_pgs_ignore not found")
}

defer fp.Close()

buf := new(strings.Builder)
_, err = io.Copy(buf, fp)
if err != nil {
Expand Down Expand Up @@ -306,11 +306,14 @@ func (h *UploadAssetHandler) Write(s ssh.Session, entry *sendutils.FileEntry) (s
// calculate the filsize difference between the same file already
// stored and the updated file being uploaded
assetFilename := shared.GetAssetFileName(entry)
_, info, _ := h.Storage.GetObject(bucket, assetFilename)
obj, info, _ := h.Storage.GetObject(bucket, assetFilename)
var curFileSize int64
if info != nil {
curFileSize = info.Size
}
if obj != nil {
defer obj.Close()
}

denylist := getDenylist(s)
if denylist == nil {
Expand Down
3 changes: 2 additions & 1 deletion pgs/web_asset_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// before redirecting, this saves a hop that will just end up a 404
if !hasProtocol(fp.Filepath) && strings.HasSuffix(fp.Filepath, "/") {
next := filepath.Join(h.ProjectDir, fp.Filepath, "index.html")
_, _, err := h.Storage.GetObject(h.Bucket, next)
obj, _, err := h.Storage.GetObject(h.Bucket, next)
if err != nil {
continue
}
defer obj.Close()
}
logger.Info(
"redirecting request",
Expand Down

0 comments on commit 894e7de

Please sign in to comment.