mirror of https://github.com/Chocobozzz/PeerTube
Avoid uploading empty master file
parent
296d07c6fe
commit
72d606dc07
|
@ -184,11 +184,15 @@ class MuxingSession extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private watchMasterFile () {
|
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 (path !== join(this.outDirectory, this.streamingPlaylist.playlistFilename)) return
|
||||||
if (this.masterPlaylistCreated === true) return
|
if (this.masterPlaylistCreated === true) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const masterPlaylistContent = await readFile(path, 'utf8')
|
||||||
|
// Not generated yet
|
||||||
|
if (!masterPlaylistContent) return
|
||||||
|
|
||||||
if (this.streamingPlaylist.storage === VideoStorage.OBJECT_STORAGE) {
|
if (this.streamingPlaylist.storage === VideoStorage.OBJECT_STORAGE) {
|
||||||
const url = await storeHLSFileFromFilename(this.streamingPlaylist, this.streamingPlaylist.playlistFilename)
|
const url = await storeHLSFileFromFilename(this.streamingPlaylist, this.streamingPlaylist.playlistFilename)
|
||||||
|
|
||||||
|
@ -205,6 +209,9 @@ class MuxingSession extends EventEmitter {
|
||||||
this.masterPlaylistCreated = true
|
this.masterPlaylistCreated = true
|
||||||
|
|
||||||
logger.info('Master playlist file for %s has been created', this.videoUUID, this.lTags())
|
logger.info('Master playlist file for %s has been created', this.videoUUID, this.lTags())
|
||||||
|
|
||||||
|
watcher.close()
|
||||||
|
.catch(err => logger.error('Cannot close watcher', { err }))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue