fix: generate unique file names for custom game icons to bypass cache

This commit is contained in:
Gökhan Bulut
2026-04-30 07:17:13 +03:00
parent b8902789af
commit c0048dab1c
@@ -32,8 +32,19 @@ const downloadIcon = async (
objectId: string,
iconUrls: (string | null | undefined)[]
): Promise<string | null> => {
const validUrls = iconUrls.filter(isValidUrl);
if (validUrls.length === 0) {
logger.warn("No valid icon URLs found for game shortcut");
return null;
}
const urlHash = Buffer.from(validUrls[0])
.toString("base64")
.replace(/[^a-zA-Z0-9]/g, "")
.substring(0, 16);
const iconDir = path.join(ASSETS_PATH, `${shop}-${objectId}`);
const iconPath = path.join(iconDir, "icon.ico");
const iconPath = path.join(iconDir, `icon-${urlHash}.ico`);
try {
if (fs.existsSync(iconPath)) {
@@ -43,13 +54,6 @@ const downloadIcon = async (
// Ignore fs errors
}
const validUrls = iconUrls.filter(isValidUrl);
if (validUrls.length === 0) {
logger.warn("No valid icon URLs found for game shortcut");
return null;
}
fs.mkdirSync(iconDir, { recursive: true });
for (const iconUrl of validUrls) {