feat(server): de-duplication (#557)

* feat(server): remove un-used deviceAssetId cols.

* feat(server): return 409 if asset is duplicated

* feat(server): replace old unique constaint

* feat(server): strip deviceId in file path

* feat(server): skip duplicate asset

* chore(server): revert changes

* fix(server): asset test spec

* fix(server): checksum generation for uploaded assets

* fix(server): make sure generation queue run after migraion

* feat(server): remove temp file

* chore(server): remove dead code
This commit is contained in:
Thanh Pham
2022-09-06 02:45:38 +07:00
committed by GitHub
parent 2677ddccaa
commit a467936e73
9 changed files with 64 additions and 18 deletions
@@ -26,6 +26,7 @@ export interface IAssetRepository {
getSearchPropertiesByUserId(userId: string): Promise<SearchPropertiesDto[]>;
getAssetCountByTimeBucket(userId: string, timeBucket: TimeGroupEnum): Promise<AssetCountByTimeBucket[]>;
getAssetByTimeBucket(userId: string, getAssetByTimeBucketDto: GetAssetByTimeBucketDto): Promise<AssetEntity[]>;
getAssetByChecksum(userId: string, checksum: Buffer): Promise<AssetEntity>;
}
export const ASSET_REPOSITORY = 'ASSET_REPOSITORY';
@@ -208,4 +209,20 @@ export class AssetRepository implements IAssetRepository {
return res;
}
/**
* Get asset by checksum on the database
* @param userId
* @param checksum
*
*/
getAssetByChecksum(userId: string, checksum: Buffer): Promise<AssetEntity> {
return this.assetRepository.findOneOrFail({
where: {
userId,
checksum
},
relations: ['exifInfo'],
});
}
}