From 82e001aaaf66e98e93358dbfeb123690ba682988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arwid=20Thornstr=C3=B6m?= Date: Mon, 3 Nov 2025 10:41:31 +0100 Subject: [PATCH] disable the cleanupInteriors function but keep the functionality (#181) --- src/datasources/product-api.ts | 51 +++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/datasources/product-api.ts b/src/datasources/product-api.ts index beaf642..b695a8b 100644 --- a/src/datasources/product-api.ts +++ b/src/datasources/product-api.ts @@ -993,6 +993,9 @@ export class ProductAPI extends BaseSQLDataSource { /** * @function cleanupInteriors * @description Removes all not used interiors from a product + * + * This function is disabled until we know what to do with dynamic interiors. + * Right now its not good if interiors are removed from s3. */ async cleanupInteriors( productId: number, @@ -1003,36 +1006,38 @@ export class ProductAPI extends BaseSQLDataSource { Scopes.INTERIORS_WRITE, ]); - // Get all interior files for product on s3 - const files = await listS3Files( - CONFIG.imageBucket, - `interiors/${productId}`, - ); + // // Get all interior files for product on s3 + // const files = await listS3Files( + // CONFIG.imageBucket, + // `interiors/${productId}`, + // ); - const shouldKeep = []; - const shouldRemove = []; + // const shouldKeep = []; + // const shouldRemove = []; - // Convert to match key format from s3 - const currentUris = currentInteriors.map((item) => item.uri.substring(1)); + // // Convert to match key format from s3 + // const currentUris = currentInteriors.map((item) => item.uri.substring(1)); - // Go through all files on s3 and organize as delete or keep - for (const file of files) { - if (currentUris.includes(file.Key)) { - shouldKeep.push(file.Key); - } else { - shouldRemove.push(file.Key); - } - } + // // Go through all files on s3 and organize as delete or keep + // for (const file of files) { + // if (currentUris.includes(file.Key)) { + // shouldKeep.push(file.Key); + // } else { + // shouldRemove.push(file.Key); + // } + // } // Setup all delete actions - let removed = []; - if (shouldRemove.length > 0) { - const response = await deleteFiles(CONFIG.imageBucket, shouldRemove); - removed = response.Deleted?.map((item) => item.Key) || []; - } + // let removed = []; + // if (shouldRemove.length > 0) { + // const response = await deleteFiles(CONFIG.imageBucket, shouldRemove); + // removed = response.Deleted?.map((item) => item.Key) || []; + // } // Return what we did - return { active: shouldKeep, deleted: removed }; + // This is temporary disabled until we know what to do with the interiors. + return { active: [], deleted: [] }; + // return { active: shouldKeep, deleted: removed }; } /**