mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-31 10:49:11 -04:00 
			
		
		
		
	fix(server): prevent cross-library motion photo linking, made getByChecksum library specific (#8719)
prevent cross linking
This commit is contained in:
		
							parent
							
								
									37eea2d353
								
							
						
					
					
						commit
						ec76e5ef23
					
				| @ -146,7 +146,7 @@ export interface IAssetRepository { | |||||||
|   ): Promise<AssetEntity[]>; |   ): Promise<AssetEntity[]>; | ||||||
|   getByIdsWithAllRelations(ids: string[]): Promise<AssetEntity[]>; |   getByIdsWithAllRelations(ids: string[]): Promise<AssetEntity[]>; | ||||||
|   getByDayOfYear(ownerIds: string[], monthDay: MonthDay): Promise<AssetEntity[]>; |   getByDayOfYear(ownerIds: string[], monthDay: MonthDay): Promise<AssetEntity[]>; | ||||||
|   getByChecksum(userId: string, checksum: Buffer): Promise<AssetEntity | null>; |   getByChecksum(libraryId: string, checksum: Buffer): Promise<AssetEntity | null>; | ||||||
|   getByAlbumId(pagination: PaginationOptions, albumId: string): Paginated<AssetEntity>; |   getByAlbumId(pagination: PaginationOptions, albumId: string): Paginated<AssetEntity>; | ||||||
|   getByUserId(pagination: PaginationOptions, userId: string, options?: AssetSearchOptions): Paginated<AssetEntity>; |   getByUserId(pagination: PaginationOptions, userId: string, options?: AssetSearchOptions): Paginated<AssetEntity>; | ||||||
|   getById(id: string, relations?: FindOptionsRelations<AssetEntity>): Promise<AssetEntity | null>; |   getById(id: string, relations?: FindOptionsRelations<AssetEntity>): Promise<AssetEntity | null>; | ||||||
|  | |||||||
| @ -464,7 +464,7 @@ FROM | |||||||
| WHERE | WHERE | ||||||
|   ( |   ( | ||||||
|     ( |     ( | ||||||
|       ("AssetEntity"."ownerId" = $1) |       ("AssetEntity"."libraryId" = $1) | ||||||
|       AND ("AssetEntity"."checksum" = $2) |       AND ("AssetEntity"."checksum" = $2) | ||||||
|     ) |     ) | ||||||
|   ) |   ) | ||||||
|  | |||||||
| @ -265,8 +265,8 @@ export class AssetRepository implements IAssetRepository { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   @GenerateSql({ params: [DummyValue.UUID, DummyValue.BUFFER] }) |   @GenerateSql({ params: [DummyValue.UUID, DummyValue.BUFFER] }) | ||||||
|   getByChecksum(userId: string, checksum: Buffer): Promise<AssetEntity | null> { |   getByChecksum(libraryId: string, checksum: Buffer): Promise<AssetEntity | null> { | ||||||
|     return this.repository.findOne({ where: { ownerId: userId, checksum } }); |     return this.repository.findOne({ where: { libraryId, checksum } }); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   findLivePhotoMatch(options: LivePhotoSearchOptions): Promise<AssetEntity | null> { |   findLivePhotoMatch(options: LivePhotoSearchOptions): Promise<AssetEntity | null> { | ||||||
|  | |||||||
| @ -405,7 +405,7 @@ export class MetadataService { | |||||||
|       } |       } | ||||||
|       const checksum = this.cryptoRepository.hashSha1(video); |       const checksum = this.cryptoRepository.hashSha1(video); | ||||||
| 
 | 
 | ||||||
|       let motionAsset = await this.assetRepository.getByChecksum(asset.ownerId, checksum); |       let motionAsset = await this.assetRepository.getByChecksum(asset.libraryId, checksum); | ||||||
|       if (motionAsset) { |       if (motionAsset) { | ||||||
|         this.logger.debug( |         this.logger.debug( | ||||||
|           `Asset ${asset.id}'s motion photo video with checksum ${checksum.toString( |           `Asset ${asset.id}'s motion photo video with checksum ${checksum.toString( | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user