feat(server): immich checksum header (#9229)

* feat: dedupe by checksum header

* chore: open api
This commit is contained in:
Jason Rasmussen
2024-05-02 15:42:26 -04:00
committed by GitHub
parent 16706f7f49
commit ec4eb7cd19
17 changed files with 165 additions and 19 deletions

View File

@@ -5,6 +5,7 @@ import { AlbumEntity, AssetOrder } from 'src/entities/album.entity';
import { AssetJobStatusEntity } from 'src/entities/asset-job-status.entity';
import { AssetEntity, AssetType } from 'src/entities/asset.entity';
import { ExifEntity } from 'src/entities/exif.entity';
import { LibraryType } from 'src/entities/library.entity';
import { PartnerEntity } from 'src/entities/partner.entity';
import { SmartInfoEntity } from 'src/entities/smart-info.entity';
import {
@@ -273,6 +274,23 @@ export class AssetRepository implements IAssetRepository {
return this.repository.findOne({ where: { libraryId, checksum } });
}
@GenerateSql({ params: [DummyValue.UUID, DummyValue.BUFFER] })
async getUploadAssetIdByChecksum(ownerId: string, checksum: Buffer): Promise<string | undefined> {
const asset = await this.repository.findOne({
select: { id: true },
where: {
ownerId,
checksum,
library: {
type: LibraryType.UPLOAD,
},
},
withDeleted: true,
});
return asset?.id;
}
findLivePhotoMatch(options: LivePhotoSearchOptions): Promise<AssetEntity | null> {
const { ownerId, otherAssetId, livePhotoCID, type } = options;