diff --git a/apps/backend/src/app/modules/maps/maps.service.ts b/apps/backend/src/app/modules/maps/maps.service.ts index 141e98188..fabaf27c1 100644 --- a/apps/backend/src/app/modules/maps/maps.service.ts +++ b/apps/backend/src/app/modules/maps/maps.service.ts @@ -552,6 +552,15 @@ export class MapsService { const hasVmf = vmfFiles?.length > 0; const bspHash = FileStoreService.getHashForBuffer(bspFile.buffer); + // Check for duplicate map hash + const existingMap = await this.db.mMap.exists({ + where: { versions: { some: { bspHash } } } + }); + + if (existingMap) { + throw new ConflictException('Map with this file hash already exists'); + } + let map: Awaited>; const tasks: Promise[] = [ @@ -661,6 +670,15 @@ export class MapsService { const hasVmf = vmfFiles?.length > 0; const bspHash = FileStoreService.getHashForBuffer(bspFile.buffer); + // Check for duplicate map hash + const existingMap = await this.db.mMap.exists({ + where: { versions: { some: { bspHash } } } + }); + + if (existingMap) { + throw new ConflictException('Map with this file hash already exists'); + } + let zonesStr: string; let zones: MapZones; if (dto.zones) {