aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-05-19 11:03:47 +0200
committerChocobozzz <me@florianbigard.com>2023-05-19 11:03:47 +0200
commit72d606dc07543b04c18476b3cb4bf9d08aa74358 (patch)
treefea78ce6c86993ba4d3d195dcf3f4f12ad4a1c3d
parent296d07c6fe55120492aef9cfe8fe5aeb9065a11d (diff)
downloadPeerTube-72d606dc07543b04c18476b3cb4bf9d08aa74358.tar.gz
PeerTube-72d606dc07543b04c18476b3cb4bf9d08aa74358.tar.zst
PeerTube-72d606dc07543b04c18476b3cb4bf9d08aa74358.zip
Avoid uploading empty master file
-rw-r--r--server/lib/live/shared/muxing-session.ts9
1 files changed, 8 insertions, 1 deletions
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 {
184 } 184 }
185 185
186 private watchMasterFile () { 186 private watchMasterFile () {
187 this.filesWatcher.on('add', async path => { 187 const watcher = this.filesWatcher.on('change', async path => {
188 if (path !== join(this.outDirectory, this.streamingPlaylist.playlistFilename)) return 188 if (path !== join(this.outDirectory, this.streamingPlaylist.playlistFilename)) return
189 if (this.masterPlaylistCreated === true) return 189 if (this.masterPlaylistCreated === true) return
190 190
191 try { 191 try {
192 const masterPlaylistContent = await readFile(path, 'utf8')
193 // Not generated yet
194 if (!masterPlaylistContent) return
195
192 if (this.streamingPlaylist.storage === VideoStorage.OBJECT_STORAGE) { 196 if (this.streamingPlaylist.storage === VideoStorage.OBJECT_STORAGE) {
193 const url = await storeHLSFileFromFilename(this.streamingPlaylist, this.streamingPlaylist.playlistFilename) 197 const url = await storeHLSFileFromFilename(this.streamingPlaylist, this.streamingPlaylist.playlistFilename)
194 198
@@ -205,6 +209,9 @@ class MuxingSession extends EventEmitter {
205 this.masterPlaylistCreated = true 209 this.masterPlaylistCreated = true
206 210
207 logger.info('Master playlist file for %s has been created', this.videoUUID, this.lTags()) 211 logger.info('Master playlist file for %s has been created', this.videoUUID, this.lTags())
212
213 watcher.close()
214 .catch(err => logger.error('Cannot close watcher', { err }))
208 }) 215 })
209 } 216 }
210 217