mirror of
https://github.com/immich-app/immich.git
synced 2025-12-23 09:15:05 +03:00
working e2e
This commit is contained in:
@@ -35,20 +35,15 @@ export class AssetUploadController {
|
||||
return this.service.cancelUpload(auth, id, response);
|
||||
}
|
||||
|
||||
@Head(':id')
|
||||
@Authenticated({ sharedLink: true, permission: Permission.AssetUpload })
|
||||
getUploadStatus(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto, @Res() response: Response): Promise<void> {
|
||||
return this.service.getUploadStatus(auth, id, response);
|
||||
}
|
||||
|
||||
@Options()
|
||||
@Authenticated({ sharedLink: true, permission: Permission.AssetUpload })
|
||||
getUploadOptions(@Res() response: Response): Promise<void> {
|
||||
return this.service.getUploadOptions(response);
|
||||
}
|
||||
|
||||
@Head(':id')
|
||||
@Authenticated({ sharedLink: true, permission: Permission.AssetUpload })
|
||||
getUploadStatus(
|
||||
@Auth() auth: AuthDto,
|
||||
@Param() { id }: UUIDParamDto,
|
||||
@Req() request: Request,
|
||||
@Res() response: Response,
|
||||
): Promise<void> {
|
||||
return this.service.getUploadStatus(auth, id, request, response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export class AssetUploadService extends BaseService {
|
||||
}
|
||||
|
||||
const location = `/api/upload/${assetId}`;
|
||||
// this.sendInterimResponse(response, location);
|
||||
this.sendInterimResponse(response, location);
|
||||
|
||||
await this.storageRepository.mkdir(folder);
|
||||
let checksumBuffer: Buffer | undefined;
|
||||
@@ -264,7 +264,20 @@ export class AssetUploadService extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
async getUploadStatus(auth: AuthDto, assetId: string, request: Request, response: Response) {
|
||||
async cancelUpload(auth: AuthDto, assetId: string, response: Response): Promise<void> {
|
||||
const asset = await this.assetRepository.getCompletionMetadata(assetId, auth.user.id);
|
||||
if (!asset) {
|
||||
response.status(404).send('Asset not found');
|
||||
return;
|
||||
}
|
||||
if (asset.status !== AssetStatus.Partial) {
|
||||
return this.sendAlreadyCompletedProblem(response);
|
||||
}
|
||||
await this.removeAsset(assetId, asset.path);
|
||||
response.status(204).send();
|
||||
}
|
||||
|
||||
async getUploadStatus(auth: AuthDto, assetId: string, response: Response) {
|
||||
return this.databaseRepository.withUuidLock(assetId, async () => {
|
||||
const asset = await this.assetRepository.getCompletionMetadata(assetId, auth.user.id);
|
||||
if (!asset) {
|
||||
@@ -289,19 +302,6 @@ export class AssetUploadService extends BaseService {
|
||||
response.status(204).setHeader('Upload-Limit', 'min-size=0').setHeader('Allow', 'POST, OPTIONS').send();
|
||||
}
|
||||
|
||||
async cancelUpload(auth: AuthDto, assetId: string, response: Response): Promise<void> {
|
||||
const asset = await this.assetRepository.getCompletionMetadata(assetId, auth.user.id);
|
||||
if (!asset) {
|
||||
response.status(404).send('Asset not found');
|
||||
return;
|
||||
}
|
||||
if (asset.status !== AssetStatus.Partial) {
|
||||
return this.sendAlreadyCompletedProblem(response);
|
||||
}
|
||||
await this.removeAsset(assetId, asset.path);
|
||||
response.status(204).send();
|
||||
}
|
||||
|
||||
private async onComplete(data: { assetId: string; path: string; size: number; fileModifiedAt: Date }): Promise<void> {
|
||||
const { assetId, path, size, fileModifiedAt } = data;
|
||||
const jobData = { name: JobName.AssetExtractMetadata, data: { id: assetId, source: 'upload' } } as const;
|
||||
|
||||
Reference in New Issue
Block a user