fix(api/v2): close export reader when commit fails before streaming
If s.Commit() fails after loading the export file, the StreamResponse callback that would close the reader never runs, leaking the open object-storage/file handle. Close it explicitly on that error path.
This commit is contained in:
parent
8c72e83a4d
commit
ee8dbf82ba
|
|
@ -146,6 +146,8 @@ func userExportDownload(ctx context.Context, in *userExportPasswordBody) (*huma.
|
|||
// valid after the commit; the StreamResponse callback runs after this returns.
|
||||
if err := s.Commit(); err != nil {
|
||||
_ = s.Rollback()
|
||||
// The stream callback (which closes the reader) won't run on this error path.
|
||||
_ = exportFile.File.Close()
|
||||
return nil, translateDomainError(err)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue