Skip to content

Commit

Permalink
feat(back): check if map exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jef committed Dec 12, 2024
1 parent 07c59f6 commit 3170480
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions apps/backend/src/app/modules/maps/maps.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReturnType<typeof this.createMapDbEntry>>;

const tasks: Promise<any>[] = [
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3170480

Please sign in to comment.