overleaf/server-ce/hotfix/4.2.7/pr_19296.patch
Jakob Ackermann 788009330c Merge pull request #19357 from overleaf/msm-hotfix-4-2-7
[CE/SP] Hotfix 4.2.7/5.0.7

GitOrigin-RevId: e36a5af392c2356d4068a98acc2d637d879392f8
2024-07-15 09:05:06 +00:00

22 lines
807 B
Diff

--- a/services/clsi/app/js/LatexRunner.js
+++ b/services/clsi/app/js/LatexRunner.js
@@ -110,11 +110,14 @@ function _writeLogOutput(projectId, directory, output, callback) {
// internal method for writing non-empty log files
function _writeFile(file, content, cb) {
if (content && content.length > 0) {
- fs.writeFile(file, content, err => {
- if (err) {
- logger.error({ err, projectId, file }, 'error writing log file') // don't fail on error
- }
- cb()
+ fs.unlink(file, () => {
+ fs.writeFile(file, content, { flag: 'wx' }, err => {
+ if (err) {
+ // don't fail on error
+ logger.error({ err, projectId, file }, 'error writing log file')
+ }
+ cb()
+ })
})
} else {
cb()