From 72d606dc07543b04c18476b3cb4bf9d08aa74358 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 19 May 2023 11:03:47 +0200 Subject: [PATCH] Avoid uploading empty master file --- server/lib/live/shared/muxing-session.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/lib/live/shared/muxing-session.ts b/server/lib/live/shared/muxing-session.ts index 6632499ff..c9e5df906 100644 --- a/server/lib/live/shared/muxing-session.ts +++ b/server/lib/live/shared/muxing-session.ts @@ -184,11 +184,15 @@ class MuxingSession extends EventEmitter { } private watchMasterFile () { - this.filesWatcher.on('add', async path => { + const watcher = this.filesWatcher.on('change', async path => { if (path !== join(this.outDirectory, this.streamingPlaylist.playlistFilename)) return if (this.masterPlaylistCreated === true) return try { + const masterPlaylistContent = await readFile(path, 'utf8') + // Not generated yet + if (!masterPlaylistContent) return + if (this.streamingPlaylist.storage === VideoStorage.OBJECT_STORAGE) { const url = await storeHLSFileFromFilename(this.streamingPlaylist, this.streamingPlaylist.playlistFilename) @@ -205,6 +209,9 @@ class MuxingSession extends EventEmitter { this.masterPlaylistCreated = true logger.info('Master playlist file for %s has been created', this.videoUUID, this.lTags()) + + watcher.close() + .catch(err => logger.error('Cannot close watcher', { err })) }) } -- 2.41.0