1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-29 15:11:58 +00:00

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 <jrasm91@gmail.com>
This commit is contained in:
Min Idzelis 2024-06-05 09:30:19 -04:00 committed by GitHub
parent cf223dc98c
commit ce985ef8f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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();