Skip to content

Commit

Permalink
Fix graceful terminate
Browse files Browse the repository at this point in the history
  • Loading branch information
blmhemu committed Apr 23, 2024
1 parent 7e24722 commit 5dc1d27
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pkg/filestore/filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ import (
"github.com/tus/tusd/v2/pkg/handler"
)

var defaultFilePerm = os.FileMode(0664)
var defaultDirectoryPerm = os.FileMode(0754)
var (
defaultFilePerm = os.FileMode(0664)
defaultDirectoryPerm = os.FileMode(0754)
)

// See the handler.DataStore interface for documentation about the different
// methods.
Expand Down Expand Up @@ -172,13 +174,11 @@ func (upload *fileUpload) GetReader(ctx context.Context) (io.ReadCloser, error)
}

func (upload *fileUpload) Terminate(ctx context.Context) error {
if err := os.Remove(upload.infoPath); err != nil {
return err
}
if err := os.Remove(upload.binPath); err != nil {
return err
}
return nil
// Ignore errors when removing bin
// This is to account for bin removed, but info not removed
// This can happen say if the server crashes after removing the bin file
os.Remove(upload.binPath)
return os.Remove(upload.infoPath)
}

func (upload *fileUpload) ConcatUploads(ctx context.Context, uploads []handler.Upload) (err error) {
Expand Down

0 comments on commit 5dc1d27

Please sign in to comment.