aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/live/live-segment-sha-store.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-05-16 10:06:07 +0200
committerChocobozzz <me@florianbigard.com>2023-05-16 10:06:07 +0200
commit49b80bd9e1d285dd555f95eb8deecc978ecfb227 (patch)
treeaa8af00b7d0034286dd9b9b930ce4cd50a7bd68c /server/lib/live/live-segment-sha-store.ts
parent0d6a8289fb5ce7466f74a0514b3a6e620bfa2e59 (diff)
downloadPeerTube-49b80bd9e1d285dd555f95eb8deecc978ecfb227.tar.gz
PeerTube-49b80bd9e1d285dd555f95eb8deecc978ecfb227.tar.zst
PeerTube-49b80bd9e1d285dd555f95eb8deecc978ecfb227.zip
Use atomic rename
Diffstat (limited to 'server/lib/live/live-segment-sha-store.ts')
-rw-r--r--server/lib/live/live-segment-sha-store.ts6
1 files changed, 3 insertions, 3 deletions
diff --git a/server/lib/live/live-segment-sha-store.ts b/server/lib/live/live-segment-sha-store.ts
index 17e0c6a82..1a0a93985 100644
--- a/server/lib/live/live-segment-sha-store.ts
+++ b/server/lib/live/live-segment-sha-store.ts
@@ -1,4 +1,4 @@
1import { move, writeJson } from 'fs-extra' 1import { rename, writeJson } from 'fs-extra'
2import PQueue from 'p-queue' 2import PQueue from 'p-queue'
3import { basename } from 'path' 3import { basename } from 'path'
4import { mapToJSON } from '@server/helpers/core-utils' 4import { mapToJSON } from '@server/helpers/core-utils'
@@ -72,9 +72,9 @@ class LiveSegmentShaStore {
72 72
73 private writeToDisk () { 73 private writeToDisk () {
74 return this.writeQueue.add(async () => { 74 return this.writeQueue.add(async () => {
75 // Atomic write 75 // Atomic write: use rename instead of move that is not atomic
76 await writeJson(this.sha256PathTMP, mapToJSON(this.segmentsSha256)) 76 await writeJson(this.sha256PathTMP, mapToJSON(this.segmentsSha256))
77 await move(this.sha256PathTMP, this.sha256Path, { overwrite: true }) 77 await rename(this.sha256PathTMP, this.sha256Path)
78 78
79 if (this.sendToObjectStorage) { 79 if (this.sendToObjectStorage) {
80 const url = await storeHLSFileFromPath(this.streamingPlaylist, this.sha256Path) 80 const url = await storeHLSFileFromPath(this.streamingPlaylist, this.sha256Path)