From 49b80bd9e1d285dd555f95eb8deecc978ecfb227 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 16 May 2023 10:06:07 +0200 Subject: Use atomic rename --- server/lib/live/live-segment-sha-store.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'server/lib/live') 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 @@ -import { move, writeJson } from 'fs-extra' +import { rename, writeJson } from 'fs-extra' import PQueue from 'p-queue' import { basename } from 'path' import { mapToJSON } from '@server/helpers/core-utils' @@ -72,9 +72,9 @@ class LiveSegmentShaStore { private writeToDisk () { return this.writeQueue.add(async () => { - // Atomic write + // Atomic write: use rename instead of move that is not atomic await writeJson(this.sha256PathTMP, mapToJSON(this.segmentsSha256)) - await move(this.sha256PathTMP, this.sha256Path, { overwrite: true }) + await rename(this.sha256PathTMP, this.sha256Path) if (this.sendToObjectStorage) { const url = await storeHLSFileFromPath(this.streamingPlaylist, this.sha256Path) -- cgit v1.2.3