Atomic write
This commit is contained in:
parent
9692192df4
commit
1359bd9747
|
@ -1238,6 +1238,15 @@
|
|||
"integrity": "sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/write-file-atomic": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/write-file-atomic/-/write-file-atomic-3.0.0.tgz",
|
||||
"integrity": "sha512-XrvNv7CBEveBoWkGU4ZxuyeL7iaYVr609VjlNAe+VaS8N9stTvGwp5IZgFP+QDbiRQV/R7MmipPsgAhlf5LZzQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/yargs": {
|
||||
"version": "15.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.4.tgz",
|
||||
|
@ -3530,8 +3539,7 @@
|
|||
"imurmurhash": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
|
||||
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
|
||||
"dev": true
|
||||
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o="
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
|
@ -7761,7 +7769,6 @@
|
|||
"version": "3.1.5",
|
||||
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
|
||||
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-typedarray": "^1.0.0"
|
||||
}
|
||||
|
@ -8232,7 +8239,6 @@
|
|||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz",
|
||||
"integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"imurmurhash": "^0.1.4",
|
||||
"is-typedarray": "^1.0.0",
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"react": "^16.13.0",
|
||||
"react-dom": "^16.13.0",
|
||||
"smtp-server": "^3.6.0",
|
||||
"write-file-atomic": "^3.0.3",
|
||||
"xmlbuilder2": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -24,6 +25,7 @@
|
|||
"@types/react": "^16.9.29",
|
||||
"@types/react-dom": "^16.9.5",
|
||||
"@types/smtp-server": "^3.5.4",
|
||||
"@types/write-file-atomic": "^3.0.0",
|
||||
"axios": "^0.19.2",
|
||||
"concurrently": "^5.1.0",
|
||||
"jest": "^25.2.4",
|
||||
|
|
|
@ -5,6 +5,7 @@ import React from "react";
|
|||
import ReactDOMServer from "react-dom/server";
|
||||
import * as xmlbuilder2 from "xmlbuilder2";
|
||||
import { promises as fs } from "fs";
|
||||
import writeFileAtomic from "write-file-atomic";
|
||||
import cryptoRandomString from "crypto-random-string";
|
||||
|
||||
export const webServer = express()
|
||||
|
@ -101,7 +102,7 @@ export const emailServer = new SMTPServer({
|
|||
xml.feed.entry.unshift(entry);
|
||||
while (xml.feed.entry.length > 0 && renderXML(xml).length > 500_000)
|
||||
xml.feed.entry.pop();
|
||||
await fs.writeFile(path, renderXML(xml));
|
||||
await writeFileAtomic(path, renderXML(xml));
|
||||
}
|
||||
callback();
|
||||
})().catch(error => {
|
||||
|
|
Loading…
Reference in New Issue