Skip to content

Commit

Permalink
images: Wait for more promises in theme functions
Browse files Browse the repository at this point in the history
  • Loading branch information
slmnio committed Jun 16, 2024
1 parent 08ba6fd commit 5a15800
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/src/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ module.exports = ({ app, cors, Cache }) => {
themeCode = `team-${themeThing?.code || cleanID(themeThing?.id)}`;
}

let filePath = await fullGetURL(logo, "orig", null);
let filePath = await getOrWaitForDownload(logo.url, logo._autoFilename, "orig");

let filename = themeColor.replace("#", "") + "_" + logo._autoFilename;
let sizeText = `theme-${size}-${padding}`;
Expand Down Expand Up @@ -457,7 +457,7 @@ module.exports = ({ app, cors, Cache }) => {
let logos = await Promise.all(teams.map(async team => {
const logo = await Cache.getAttachment(team.theme?.default_logo?.[0]?.id);
if (!logo) return null;
let filePath = await fullGetURL(logo, "orig", null);
let filePath = await getOrWaitForDownload(logo.url, logo._autoFilename, "orig");
let themeColor = (team.theme.color_logo_background || team.theme.color_theme || "#222222").trim();

let resizedLogo = await sharp(filePath).resize({
Expand All @@ -483,7 +483,7 @@ module.exports = ({ app, cors, Cache }) => {
let eventTheme = event?.theme?.length ? await Cache.get(event?.theme?.[0]) : null;
const logo = await Cache.getAttachment(eventTheme?.default_logo?.[0]?.id);
if (!logo) return null;
let eventLogoFilePath = await fullGetURL(logo, "orig", null);
let eventLogoFilePath = await getOrWaitForDownload(logo.url, logo._autoFilename, "orig");
eventLogo = await sharp(eventLogoFilePath).resize({
height: Math.floor(size * 0.20),
width: Math.floor(size * 0.25),
Expand Down Expand Up @@ -525,7 +525,7 @@ module.exports = ({ app, cors, Cache }) => {
if (!event.theme?.id) return res.status(400).send("No event theme data");
let themeColor = event.theme.color_logo_background || event.theme.color_theme || "#222222";

let filePath = await fullGetURL(event.theme.default_logo[0], "orig", null);
let filePath = await getOrWaitForDownload(event.theme.default_logo[0].url, event.theme.default_logo[0]._autoFilename, "orig");

let resizedLogo = await sharp(filePath).resize({
width: width - padding,
Expand Down

0 comments on commit 5a15800

Please sign in to comment.