From ce985ef8f8caf13f7f753c2d378fde75ea89f699 Mon Sep 17 00:00:00 2001 From: Min Idzelis Date: Wed, 5 Jun 2024 09:30:19 -0400 Subject: [PATCH] fix: AssetInterceptor "can't set headers after they are sent" (#9987) * fix: AssetInterceptor "can't set headers after they are sent" * chore: remove long comment --------- Co-authored-by: Jason Rasmussen --- server/src/middleware/asset-upload.interceptor.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/middleware/asset-upload.interceptor.ts b/server/src/middleware/asset-upload.interceptor.ts index 5a460fb2d9..0f38c34259 100644 --- a/server/src/middleware/asset-upload.interceptor.ts +++ b/server/src/middleware/asset-upload.interceptor.ts @@ -1,6 +1,7 @@ import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common'; import { Response } from 'express'; -import { AssetMediaResponseDto } from 'src/dtos/asset-media-response.dto'; +import { of } from 'rxjs'; +import { AssetMediaResponseDto, AssetMediaStatus } from 'src/dtos/asset-media-response.dto'; import { ImmichHeader } from 'src/dtos/auth.dto'; import { AuthenticatedRequest } from 'src/middleware/auth.guard'; import { AssetMediaService } from 'src/services/asset-media.service'; @@ -17,7 +18,8 @@ export class AssetUploadInterceptor implements NestInterceptor { const checksum = fromMaybeArray(req.headers[ImmichHeader.CHECKSUM]); const response = await this.service.getUploadAssetIdByChecksum(req.user, checksum); if (response) { - res.status(200).send(response); + res.status(200); + return of({ status: AssetMediaStatus.DUPLICATE, id: response.id }); } return next.handle();