ActivityPub-federated video streaming platform using P2P directly in your web browser
Use atomic rename
Chocobozzz49b80bd9e1d2
diff --git a/server/lib/live/live-segment-sha-store.ts b/server/lib/live/live-segment-sha-store.tsindex 17e0c6a829..1a0a939855 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 atomicawait 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)diff --git a/server/lib/object-storage/shared/object-storage-helpers.ts b/server/lib/object-storage/shared/object-storage-helpers.tsindex f517c5f694..861c490d79 100644--- a/server/lib/object-storage/shared/object-storage-helpers.ts+++ b/server/lib/object-storage/shared/object-storage-helpers.ts@@ -278,7 +278,7 @@ async function uploadToStorage (options: {logger.debug('Completed %s%s in bucket %s',- bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, lTags()+ bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, { ...lTags(), reseponseMetadata: response.$metadata })return getInternalUrl(bucketInfo, objectStorageKey)