Staged media flushing for improved feedback and performance.
This commit is contained in:
parent
f3e82375ad
commit
1a34dbd76d
|
@ -447,6 +447,7 @@ module.exports = {
|
|||
attempts: 2,
|
||||
fetchStreams: true,
|
||||
streamConcurrency: 2, // max number of video streams (m3u8 etc.) to fetch and process at once
|
||||
flushWindow: 1000,
|
||||
},
|
||||
titleSlugLength: 50,
|
||||
};
|
||||
|
|
|
@ -1056,7 +1056,8 @@ async function flushOrphanedMedia() {
|
|||
)
|
||||
.as('associations'),
|
||||
)
|
||||
.whereRaw('associations.media_id = media.id'),
|
||||
.whereRaw('associations.media_id = media.id')
|
||||
.limit(config.media.flushWindow),
|
||||
)
|
||||
.returning(['media.id', 'media.is_s3', 'media.path', 'media.thumbnail', 'media.lazy'])
|
||||
.delete();
|
||||
|
@ -1085,6 +1086,10 @@ async function flushOrphanedMedia() {
|
|||
} catch (error) {
|
||||
logger.warn(`Failed to clear temporary media directory: ${error.message}`);
|
||||
}
|
||||
|
||||
if (orphanedMedia.length > 0 && orphanedMedia.length >= config.media.flushWindow) {
|
||||
await flushOrphanedMedia();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Reference in New Issue