mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-03 19:29:32 -05:00 
			
		
		
		
	fix(server): generate thumbnail job uses stale path (#2236)
* fix(server): generate thumbnail job' using stale path * add query for webp generation * revert query for webp because it happens after files are moved * Add log info
This commit is contained in:
		
							parent
							
								
									1564807aa0
								
							
						
					
					
						commit
						eb9481b668
					
				@ -79,6 +79,7 @@ describe(MediaService.name, () => {
 | 
			
		||||
 | 
			
		||||
  describe('handleGenerateJpegThumbnail', () => {
 | 
			
		||||
    it('should generate a thumbnail for an image', async () => {
 | 
			
		||||
      assetMock.getByIds.mockResolvedValue([assetEntityStub.image]);
 | 
			
		||||
      await sut.handleGenerateJpegThumbnail({ asset: _.cloneDeep(assetEntityStub.image) });
 | 
			
		||||
 | 
			
		||||
      expect(storageMock.mkdirSync).toHaveBeenCalledWith('upload/thumbs/user-id');
 | 
			
		||||
@ -94,6 +95,7 @@ describe(MediaService.name, () => {
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    it('should generate a thumbnail for an image from exif', async () => {
 | 
			
		||||
      assetMock.getByIds.mockResolvedValue([assetEntityStub.image]);
 | 
			
		||||
      mediaMock.resize.mockRejectedValue(new Error('unsupported format'));
 | 
			
		||||
 | 
			
		||||
      await sut.handleGenerateJpegThumbnail({ asset: _.cloneDeep(assetEntityStub.image) });
 | 
			
		||||
@ -114,6 +116,7 @@ describe(MediaService.name, () => {
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    it('should generate a thumbnail for a video', async () => {
 | 
			
		||||
      assetMock.getByIds.mockResolvedValue([assetEntityStub.video]);
 | 
			
		||||
      await sut.handleGenerateJpegThumbnail({ asset: _.cloneDeep(assetEntityStub.video) });
 | 
			
		||||
 | 
			
		||||
      expect(storageMock.mkdirSync).toHaveBeenCalledWith('upload/thumbs/user-id');
 | 
			
		||||
@ -130,7 +133,7 @@ describe(MediaService.name, () => {
 | 
			
		||||
 | 
			
		||||
    it('should queue some jobs', async () => {
 | 
			
		||||
      const asset = _.cloneDeep(assetEntityStub.image);
 | 
			
		||||
 | 
			
		||||
      assetMock.getByIds.mockResolvedValue([asset]);
 | 
			
		||||
      await sut.handleGenerateJpegThumbnail({ asset });
 | 
			
		||||
 | 
			
		||||
      expect(jobMock.queue).toHaveBeenCalledWith({ name: JobName.GENERATE_WEBP_THUMBNAIL, data: { asset } });
 | 
			
		||||
@ -140,6 +143,7 @@ describe(MediaService.name, () => {
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    it('should log an error', async () => {
 | 
			
		||||
      assetMock.getByIds.mockResolvedValue([assetEntityStub.image]);
 | 
			
		||||
      mediaMock.resize.mockRejectedValue(new Error('unsupported format'));
 | 
			
		||||
      mediaMock.extractThumbnailFromExif.mockRejectedValue(new Error('unsupported format'));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -43,7 +43,14 @@ export class MediaService {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async handleGenerateJpegThumbnail(data: IAssetJob): Promise<void> {
 | 
			
		||||
    const { asset } = data;
 | 
			
		||||
    const [asset] = await this.assetRepository.getByIds([data.asset.id]);
 | 
			
		||||
 | 
			
		||||
    if (!asset) {
 | 
			
		||||
      this.logger.warn(
 | 
			
		||||
        `Asset not found: ${data.asset.id} - Original Path: ${data.asset.originalPath} - Resize Path: ${data.asset.resizePath}`,
 | 
			
		||||
      );
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    try {
 | 
			
		||||
      const resizePath = this.storageCore.getFolderLocation(StorageFolder.THUMBNAILS, asset.ownerId);
 | 
			
		||||
@ -122,6 +129,7 @@ export class MediaService {
 | 
			
		||||
    const [asset] = await this.assetRepository.getByIds([job.asset.id]);
 | 
			
		||||
 | 
			
		||||
    if (!asset) {
 | 
			
		||||
      this.logger.warn(`Asset not found: ${job.asset.id} - Original Path: ${job.asset.originalPath}`);
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user