Staged media flushing for improved feedback and performance.
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user