Skip to content

Commit

Permalink
fix: write atomically
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwynr committed Aug 14, 2024
1 parent ad3a40b commit 873f849
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 11 deletions.
51 changes: 44 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@filen/webdav",
"version": "0.2.27",
"version": "0.2.28",
"description": "Filen WebDAV",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -39,6 +39,7 @@
"@types/lodash": "^4.14.202",
"@types/mime-types": "^2.1.4",
"@types/uuid": "^10.0.0",
"@types/write-file-atomic": "^4.0.3",
"@types/xml2js": "^0.4.14",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
Expand All @@ -61,6 +62,7 @@
"node-cache": "^5.1.2",
"selfsigned": "^2.4.1",
"uuid": "^10.0.0",
"write-file-atomic": "^5.0.1",
"xml-js-builder": "^1.0.3",
"xml2js": "^0.6.2"
}
Expand Down
7 changes: 4 additions & 3 deletions src/certs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import selfsigned from "selfsigned"
import fs from "fs-extra"
import pathModule from "path"
import { platformConfigPath } from "./utils"
import writeFileAtomic from "write-file-atomic"

/**
* Certs
Expand Down Expand Up @@ -60,9 +61,9 @@ export class Certs {
)

await Promise.all([
fs.writeFile(this.certPath, generated.cert),
fs.writeFile(this.privateKeyPath, generated.private),
fs.writeFile(this.expiryPath, (now + 86400 * 360).toString())
writeFileAtomic(this.certPath, generated.cert, "utf-8"),
writeFileAtomic(this.privateKeyPath, generated.private, "utf-8"),
writeFileAtomic(this.expiryPath, (now + 86400 * 360).toString(), "utf-8")
])

return {
Expand Down

0 comments on commit 873f849

Please sign in to comment.