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:
kolaente 2026-06-12 11:08:53 +02:00
parent 0bc930829d
commit b0c7bddb03
1 changed files with 2 additions and 0 deletions

View File

@ -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)
}