aboutsummaryrefslogtreecommitdiffhomepage
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
parent0d6a8289fb5ce7466f74a0514b3a6e620bfa2e59 (diff)
downloadPeerTube-49b80bd9e1d285dd555f95eb8deecc978ecfb227.tar.gz
PeerTube-49b80bd9e1d285dd555f95eb8deecc978ecfb227.tar.zst
PeerTube-49b80bd9e1d285dd555f95eb8deecc978ecfb227.zip
Use atomic rename
-rw-r--r--server/lib/live/live-segment-sha-store.ts6
-rw-r--r--server/lib/object-storage/shared/object-storage-helpers.ts2
2 files changed, 4 insertions, 4 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)
diff --git a/server/lib/object-storage/shared/object-storage-helpers.ts b/server/lib/object-storage/shared/object-storage-helpers.ts
index f517c5f69..861c490d7 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: {
278 278
279 logger.debug( 279 logger.debug(
280 'Completed %s%s in bucket %s', 280 'Completed %s%s in bucket %s',
281 bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, lTags() 281 bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, { ...lTags(), reseponseMetadata: response.$metadata }
282 ) 282 )
283 283
284 return getInternalUrl(bucketInfo, objectStorageKey) 284 return getInternalUrl(bucketInfo, objectStorageKey)