fix: report write panic

This commit is contained in:
Samuel N Cui
2022-12-13 18:09:27 +08:00
parent 8ccecd8017
commit b9355ad892
3 changed files with 6 additions and 2 deletions

View File

@@ -246,7 +246,9 @@ func (a *jobArchiveExecutor) makeTape(ctx context.Context, device, barcode, name
a.logger.WithContext(ctx).WithError(err).Warnf("open report file fail, barcode= '%s'", barcode)
} else {
defer reportFile.Close()
reportFile.Write([]byte(report.ToJSONString(false)))
tools.Wrap(ctx, func() {
reportFile.Write([]byte(report.ToJSONString(false)))
})
}
filteredJobs := make([]*acp.Job, 0, len(report.Jobs))