Skip to content

Commit

Permalink
eosfs: cleanup auxiliary upload files in same function
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Sep 29, 2020
1 parent 68209cf commit a8a0823
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions pkg/storage/utils/eosfs/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,21 +307,18 @@ func (upload *fileUpload) FinishUpload(ctx context.Context) error {

// only delete the upload if it was successfully written to eos
if err == nil {
// cleanup in the background, delete might take a while and we don't need to wait for it to finish
go func() {
if err := os.Remove(upload.infoPath); err != nil {
if !os.IsNotExist(err) {
log := appctx.GetLogger(ctx)
log.Err(err).Interface("info", upload.info).Msg("eos: could not delete upload info")
}
if err := os.Remove(upload.infoPath); err != nil {
if !os.IsNotExist(err) {
log := appctx.GetLogger(ctx)
log.Err(err).Interface("info", upload.info).Msg("eos: could not delete upload info")
}
if err := os.Remove(upload.binPath); err != nil {
if !os.IsNotExist(err) {
log := appctx.GetLogger(ctx)
log.Err(err).Interface("info", upload.info).Msg("eos: could not delete upload binary")
}
}
if err := os.Remove(upload.binPath); err != nil {
if !os.IsNotExist(err) {
log := appctx.GetLogger(ctx)
log.Err(err).Interface("info", upload.info).Msg("eos: could not delete upload binary")
}
}()
}
}

// TODO: set mtime if specified in metadata
Expand Down

0 comments on commit a8a0823

Please sign in to comment.