mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-06-02 06:14:48 +02:00
fix: generate unique file names for custom game icons to bypass cache
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user