fix(plugins): cache-bust enable_automation image to enable_automation_v2.png to clear CDN/browser cache

This commit is contained in:
2026-11-07 12:24:08 +03:30
parent 5d4fda6b8e
commit 882b6dba26
2 changed files with 18 additions and 7 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

+18 -7
View File
@@ -19,17 +19,28 @@ async function main() {
let updatedCount = 0; let updatedCount = 0;
for (const seed of PLUGIN_CATALOG_SEED) { for (const seed of PLUGIN_CATALOG_SEED) {
const filename = `${seed.settingKey}.png`; // Check if there is a cache-busted _v2 version (e.g. enable_automation_v2.png)
const srcFile = join(sourceDir, filename); const baseFilename = `${seed.settingKey}.png`;
const destFile = join(targetDir, filename); const v2Filename = `${seed.settingKey}_v2.png`;
let activeFilename = baseFilename;
if (existsSync(join(sourceDir, v2Filename))) {
activeFilename = v2Filename;
copyFileSync(join(sourceDir, v2Filename), join(targetDir, v2Filename));
}
let hasImage = false; let hasImage = false;
if (existsSync(srcFile)) { const baseSrc = join(sourceDir, baseFilename);
copyFileSync(srcFile, destFile); if (existsSync(baseSrc)) {
copyFileSync(baseSrc, join(targetDir, baseFilename));
hasImage = true; hasImage = true;
} }
const imageUrl = `/uploads/plugins/${filename}`; if (activeFilename === v2Filename) {
hasImage = true;
}
const imageUrl = `/uploads/plugins/${activeFilename}`;
const res = await prisma.pluginCatalogItem.updateMany({ const res = await prisma.pluginCatalogItem.updateMany({
where: { settingKey: seed.settingKey }, where: { settingKey: seed.settingKey },
@@ -41,7 +52,7 @@ async function main() {
}); });
if (res.count > 0) { if (res.count > 0) {
console.log(`✓ Updated [${seed.settingKey}] - ${seed.titleFa} ${hasImage ? '(+ Image)' : ''}`); console.log(`✓ Updated [${seed.settingKey}] - ${seed.titleFa} -> ${imageUrl}`);
updatedCount += res.count; updatedCount += res.count;
} else { } else {
console.log(`- Item [${seed.settingKey}] not found in DB`); console.log(`- Item [${seed.settingKey}] not found in DB`);