overleaf/server-ce/hotfix/5.0.7/pr_19296.patch

23 lines
807 B
Diff
Raw Normal View History

--- 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()