diff --git a/lib/mission-uploads.ts b/lib/mission-uploads.ts index 28794171..9e8615cf 100644 --- a/lib/mission-uploads.ts +++ b/lib/mission-uploads.ts @@ -41,10 +41,11 @@ export function getMissionFileUrl(path: string): string { // Helper function to delete a mission logo export async function deleteMissionLogo(missionId: string, logoPath: string): Promise { + const normalizedPath = ensureMissionsPrefix(logoPath); + const minioPath = normalizedPath.replace(/^missions\//, ''); // Remove prefix for Minio + try { const { DeleteObjectCommand } = await import('@aws-sdk/client-s3'); - const normalizedPath = ensureMissionsPrefix(logoPath); - const minioPath = normalizedPath.replace(/^missions\//, ''); // Remove prefix for Minio logger.debug('Deleting mission logo', { missionId, @@ -71,10 +72,11 @@ export async function deleteMissionLogo(missionId: string, logoPath: string): Pr // Helper function to delete a mission attachment export async function deleteMissionAttachment(filePath: string): Promise { + const normalizedPath = ensureMissionsPrefix(filePath); + const minioPath = normalizedPath.replace(/^missions\//, ''); // Remove prefix for Minio + try { const { DeleteObjectCommand } = await import('@aws-sdk/client-s3'); - const normalizedPath = ensureMissionsPrefix(filePath); - const minioPath = normalizedPath.replace(/^missions\//, ''); // Remove prefix for Minio logger.debug('Deleting mission attachment', { minioPath