mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-19 00:18:56 +01:00
Fix:Cleaning up orphan streams on server init #2209
This commit is contained in:
parent
753ae3d7dc
commit
e687a3403e
@ -330,14 +330,15 @@ class PlaybackSessionManager {
|
|||||||
Logger.debug(`[PlaybackSessionManager] Removed session "${sessionId}"`)
|
Logger.debug(`[PlaybackSessionManager] Removed session "${sessionId}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for streams that are not in memory and remove
|
/**
|
||||||
|
* Remove all stream folders in `/metadata/streams`
|
||||||
|
*/
|
||||||
async removeOrphanStreams() {
|
async removeOrphanStreams() {
|
||||||
await fs.ensureDir(this.StreamsPath)
|
await fs.ensureDir(this.StreamsPath)
|
||||||
try {
|
try {
|
||||||
const streamsInPath = await fs.readdir(this.StreamsPath)
|
const streamsInPath = await fs.readdir(this.StreamsPath)
|
||||||
for (let i = 0; i < streamsInPath.length; i++) {
|
for (const streamId of streamsInPath) {
|
||||||
const streamId = streamsInPath[i]
|
if (/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/.test(streamId)) { // Ensure is uuidv4
|
||||||
if (streamId.startsWith('play_')) { // Make sure to only remove folders that are a stream
|
|
||||||
const session = this.sessions.find(se => se.id === streamId)
|
const session = this.sessions.find(se => se.id === streamId)
|
||||||
if (!session) {
|
if (!session) {
|
||||||
const streamPath = Path.join(this.StreamsPath, streamId)
|
const streamPath = Path.join(this.StreamsPath, streamId)
|
||||||
|
Loading…
Reference in New Issue
Block a user