From aeaba92e2dc0c55f70e76f4dd2efe160a0c4d836 Mon Sep 17 00:00:00 2001 From: Braxen Date: Thu, 7 Dec 2023 08:56:35 +0100 Subject: [PATCH] Check for ts files in storage folder --- server/src/Core/LiveStreamDVR.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/server/src/Core/LiveStreamDVR.ts b/server/src/Core/LiveStreamDVR.ts index 06fca040..084bf3a1 100644 --- a/server/src/Core/LiveStreamDVR.ts +++ b/server/src/Core/LiveStreamDVR.ts @@ -30,6 +30,7 @@ import type { BinaryStatus } from "@common/Api/About"; import type { ChannelConfig } from "@common/Config"; import { SubStatus } from "@common/Defs"; import checkDiskSpace from "check-disk-space"; +import readdirRecursive from "fs-readdir-recursive"; import i18next, { t } from "i18next"; import path from "node:path"; import type { WebSocketServer } from "ws"; @@ -476,16 +477,19 @@ export class LiveStreamDVR { public cleanLingeringVODs(): void { this.vods.forEach((vod) => { - const channel = vod.getChannel(); - if (!channel) { + let channel; + try { + channel = vod.getChannel(); + } catch (error) { log( - LOGLEVEL.WARNING, + LOGLEVEL.ERROR, "dvr.cleanLingeringVODs", `Channel ${vod.getChannel().internalName} removed but VOD ${ vod.basename } still lingering` ); } + if (!fs.existsSync(vod.filename)) { log( LOGLEVEL.WARNING, @@ -962,6 +966,19 @@ export class LiveStreamDVR { } } + // check for ts files in storage + const files = readdirRecursive(BaseConfigDataFolder.storage); + for (const file of files) { + if (file.endsWith(".ts")) { + errors.push( + `Found ts file in storage folder: ${path.join( + BaseConfigDataFolder.storage, + file + )}` + ); + } + } + return errors; }