onara
This commit is contained in:
@@ -1302,7 +1302,7 @@ export default router => {
|
||||
if (!itemid) return res.json({ success: false, msg: 'No itemid provided' }, 400);
|
||||
|
||||
const rows = await db`
|
||||
SELECT id, dest, mime, username
|
||||
SELECT id, dest, mime, username, src
|
||||
FROM items
|
||||
WHERE id = ${itemid} AND active = true AND is_deleted = false
|
||||
LIMIT 1
|
||||
@@ -1314,13 +1314,26 @@ export default router => {
|
||||
const isAdmin = !!(req.session.admin || req.session.is_moderator);
|
||||
if (!isOwner && !isAdmin) return res.json({ success: false, msg: 'Unauthorized' }, 403);
|
||||
|
||||
const ok = await queue.genThumbnail(item.dest, item.mime, item.id, '', false);
|
||||
const ok = await queue.genThumbnail(item.dest, item.mime, item.id, item.src || '', false);
|
||||
await queue.genBlurredThumbnail(item.id, false);
|
||||
|
||||
let hasCoverart = false;
|
||||
if (item.mime && item.mime.startsWith('audio/')) {
|
||||
const caFile = path.join(cfg.paths.ca, `${item.id}.webp`);
|
||||
hasCoverart = !!queue._lastCoverExtracted;
|
||||
if (!hasCoverart) {
|
||||
try {
|
||||
const stat = await fs.stat(caFile);
|
||||
hasCoverart = stat.size > 0;
|
||||
} catch (_) {}
|
||||
}
|
||||
await db`UPDATE items SET has_coverart = ${hasCoverart} WHERE id = ${item.id}`;
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
db.notify('rethumb', JSON.stringify({ item_id: item.id })).catch(() => {});
|
||||
db.notify('rethumb', JSON.stringify({ item_id: item.id, has_coverart: hasCoverart })).catch(() => {});
|
||||
audit.log(req.session.id, 'rethumb_item', 'item', item.id, {}).catch(() => {});
|
||||
return res.json({ success: true, itemid: item.id });
|
||||
return res.json({ success: true, itemid: item.id, has_coverart: hasCoverart });
|
||||
} else {
|
||||
return res.json({ success: false, msg: 'Thumbnail regeneration failed' }, 500);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user