|
|
@ -89,14 +89,18 @@ storage.crashSafeWriteFileLines = (filename, lines, callback = () => {}) => { |
|
|
|
}, |
|
|
|
}, |
|
|
|
cb => { |
|
|
|
cb => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const stream = fs.createWriteStream(tempFilename, { |
|
|
|
const stream = fs.createWriteStream(tempFilename) |
|
|
|
flags: 'w' |
|
|
|
const next = () => { |
|
|
|
}) |
|
|
|
const line = lines.shift() |
|
|
|
for (const line of lines) { |
|
|
|
if (line === undefined) { |
|
|
|
stream.write(line) |
|
|
|
stream.close(cb) |
|
|
|
stream.write('\n') |
|
|
|
} else { |
|
|
|
|
|
|
|
stream.write(line) |
|
|
|
|
|
|
|
stream.write('\n') |
|
|
|
|
|
|
|
setImmediate(next) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
stream.close(() => cb()) |
|
|
|
next() |
|
|
|
} catch (err) { |
|
|
|
} catch (err) { |
|
|
|
cb(err) |
|
|
|
cb(err) |
|
|
|
} |
|
|
|
} |
|
|
|