mirror of
https://github.com/immich-app/immich.git
synced 2025-01-02 12:48:35 +02:00
Better error message for duplicate file (#78)
* Added try/catch block for saving new asset to database * Fixed typo for email field * Added check before generating thumbnail or tag images
This commit is contained in:
parent
041c711cb9
commit
80fd664cc8
@ -78,7 +78,7 @@ class EmailInput extends StatelessWidget {
|
|||||||
return TextFormField(
|
return TextFormField(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
decoration:
|
decoration:
|
||||||
const InputDecoration(labelText: 'email', border: OutlineInputBorder(), hintText: 'youremail@email.com'),
|
const InputDecoration(labelText: 'Email', border: OutlineInputBorder(), hintText: 'youremail@email.com'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import {
|
|||||||
Response,
|
Response,
|
||||||
Headers,
|
Headers,
|
||||||
Delete,
|
Delete,
|
||||||
|
Logger,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { JwtAuthGuard } from '../../modules/immich-jwt/guards/jwt-auth.guard';
|
import { JwtAuthGuard } from '../../modules/immich-jwt/guards/jwt-auth.guard';
|
||||||
import { AssetService } from './asset.service';
|
import { AssetService } from './asset.service';
|
||||||
@ -55,9 +56,10 @@ export class AssetController {
|
|||||||
@Body(ValidationPipe) assetInfo: CreateAssetDto,
|
@Body(ValidationPipe) assetInfo: CreateAssetDto,
|
||||||
) {
|
) {
|
||||||
for (const file of uploadFiles.assetData) {
|
for (const file of uploadFiles.assetData) {
|
||||||
|
try {
|
||||||
const savedAsset = await this.assetService.createUserAsset(authUser, assetInfo, file.path, file.mimetype);
|
const savedAsset = await this.assetService.createUserAsset(authUser, assetInfo, file.path, file.mimetype);
|
||||||
|
|
||||||
if (uploadFiles.thumbnailData != null) {
|
if (uploadFiles.thumbnailData != null && savedAsset) {
|
||||||
await this.assetService.updateThumbnailInfo(savedAsset.id, uploadFiles.thumbnailData[0].path);
|
await this.assetService.updateThumbnailInfo(savedAsset.id, uploadFiles.thumbnailData[0].path);
|
||||||
await this.backgroundTaskService.tagImage(uploadFiles.thumbnailData[0].path, savedAsset);
|
await this.backgroundTaskService.tagImage(uploadFiles.thumbnailData[0].path, savedAsset);
|
||||||
await this.backgroundTaskService.detectObject(uploadFiles.thumbnailData[0].path, savedAsset);
|
await this.backgroundTaskService.detectObject(uploadFiles.thumbnailData[0].path, savedAsset);
|
||||||
@ -66,6 +68,9 @@ export class AssetController {
|
|||||||
await this.backgroundTaskService.extractExif(savedAsset, file.originalname, file.size);
|
await this.backgroundTaskService.extractExif(savedAsset, file.originalname, file.size);
|
||||||
|
|
||||||
this.wsCommunicateionGateway.server.to(savedAsset.userId).emit('on_upload_success', JSON.stringify(savedAsset));
|
this.wsCommunicateionGateway.server.to(savedAsset.userId).emit('on_upload_success', JSON.stringify(savedAsset));
|
||||||
|
} catch (e) {
|
||||||
|
Logger.error(`Error receiving upload file ${e}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'ok';
|
return 'ok';
|
||||||
|
Loading…
Reference in New Issue
Block a user