chore: Fix recursive call in getBackgroundImages when encountering empty folder placeholder

This commit is contained in:
Sean Morley
2024-06-12 19:49:55 +00:00
parent 2f5bdc052d
commit 8eb9f11708

View File

@@ -1,7 +1,7 @@
import { ensureBucketExists, getObjectUrl, s3Client } from "$lib/server/s3";
import { ListObjectsV2Command } from "@aws-sdk/client-s3";
export const getBackgroundImages = async () => {
export const getBackgroundImages = async (): Promise<string> => {
await ensureBucketExists("backgrounds");
const data = await s3Client.send(
@@ -13,6 +13,10 @@ export const getBackgroundImages = async () => {
const randomImage = randomImages[randomIndex];
if (randomImage == ".emptyFolderPlaceholder") {
return getBackgroundImages();
}
console.log(randomImage);
let url = getObjectUrl("backgrounds", randomImage as string);