fix(plugins): cache-bust enable_automation image to enable_automation_v2.png to clear CDN/browser cache
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 308 KiB |
@@ -19,17 +19,28 @@ async function main() {
|
||||
let updatedCount = 0;
|
||||
|
||||
for (const seed of PLUGIN_CATALOG_SEED) {
|
||||
const filename = `${seed.settingKey}.png`;
|
||||
const srcFile = join(sourceDir, filename);
|
||||
const destFile = join(targetDir, filename);
|
||||
// Check if there is a cache-busted _v2 version (e.g. enable_automation_v2.png)
|
||||
const baseFilename = `${seed.settingKey}.png`;
|
||||
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;
|
||||
if (existsSync(srcFile)) {
|
||||
copyFileSync(srcFile, destFile);
|
||||
const baseSrc = join(sourceDir, baseFilename);
|
||||
if (existsSync(baseSrc)) {
|
||||
copyFileSync(baseSrc, join(targetDir, baseFilename));
|
||||
hasImage = true;
|
||||
}
|
||||
|
||||
const imageUrl = `/uploads/plugins/${filename}`;
|
||||
if (activeFilename === v2Filename) {
|
||||
hasImage = true;
|
||||
}
|
||||
|
||||
const imageUrl = `/uploads/plugins/${activeFilename}`;
|
||||
|
||||
const res = await prisma.pluginCatalogItem.updateMany({
|
||||
where: { settingKey: seed.settingKey },
|
||||
@@ -41,7 +52,7 @@ async function main() {
|
||||
});
|
||||
|
||||
if (res.count > 0) {
|
||||
console.log(`✓ Updated [${seed.settingKey}] - ${seed.titleFa} ${hasImage ? '(+ Image)' : ''}`);
|
||||
console.log(`✓ Updated [${seed.settingKey}] - ${seed.titleFa} -> ${imageUrl}`);
|
||||
updatedCount += res.count;
|
||||
} else {
|
||||
console.log(`- Item [${seed.settingKey}] not found in DB`);
|
||||
|
||||
Reference in New Issue
Block a user