Ensure file is flushed before renaming it

pull/6259/head
Chocobozzz 2024-02-15 09:00:25 +01:00
parent 11458a747c
commit 8758d8ed8f
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 2 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import { logger, loggerTagsFactory } from '@server/helpers/logger.js'
import { MStreamingPlaylistVideo } from '@server/types/models/index.js'
import { buildSha256Segment } from '../hls.js'
import { storeHLSFileFromPath } from '../object-storage/index.js'
import { JFWriteOptions } from 'jsonfile'
const lTags = loggerTagsFactory('live')
@ -76,7 +77,7 @@ class LiveSegmentShaStore {
logger.debug(`Writing segment sha JSON ${this.sha256Path} of ${this.videoUUID} on disk.`, lTags(this.videoUUID))
// Atomic write: use rename instead of move that is not atomic
await writeJson(this.sha256PathTMP, mapToJSON(this.segmentsSha256))
await writeJson(this.sha256PathTMP, mapToJSON(this.segmentsSha256), { flush: true } as JFWriteOptions) // FIXME: jsonfile typings
await rename(this.sha256PathTMP, this.sha256Path)
if (this.sendToObjectStorage) {