mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-03 19:29:32 -05:00 
			
		
		
		
	fix(cli): ignore web socket when unavailable and skip metadata init (#4748)
This commit is contained in:
		
							parent
							
								
									197f336b5f
								
							
						
					
					
						commit
						68f6446718
					
				@ -67,6 +67,10 @@ describe(MetadataService.name, () => {
 | 
				
			|||||||
    );
 | 
					    );
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  afterEach(async () => {
 | 
				
			||||||
 | 
					    await sut.teardown();
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('should be defined', () => {
 | 
					  it('should be defined', () => {
 | 
				
			||||||
    expect(sut).toBeDefined();
 | 
					    expect(sut).toBeDefined();
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,7 @@ import { ExifDateTime, Tags } from 'exiftool-vendored';
 | 
				
			|||||||
import { firstDateTime } from 'exiftool-vendored/dist/FirstDateTime';
 | 
					import { firstDateTime } from 'exiftool-vendored/dist/FirstDateTime';
 | 
				
			||||||
import { constants } from 'fs/promises';
 | 
					import { constants } from 'fs/promises';
 | 
				
			||||||
import { Duration } from 'luxon';
 | 
					import { Duration } from 'luxon';
 | 
				
			||||||
 | 
					import { Subscription } from 'rxjs';
 | 
				
			||||||
import { usePagination } from '../domain.util';
 | 
					import { usePagination } from '../domain.util';
 | 
				
			||||||
import { IBaseJob, IEntityJob, JOBS_ASSET_PAGINATION_SIZE, JobName, QueueName } from '../job';
 | 
					import { IBaseJob, IEntityJob, JOBS_ASSET_PAGINATION_SIZE, JobName, QueueName } from '../job';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
@ -67,6 +68,7 @@ export class MetadataService {
 | 
				
			|||||||
  private storageCore: StorageCore;
 | 
					  private storageCore: StorageCore;
 | 
				
			||||||
  private configCore: SystemConfigCore;
 | 
					  private configCore: SystemConfigCore;
 | 
				
			||||||
  private oldCities?: string;
 | 
					  private oldCities?: string;
 | 
				
			||||||
 | 
					  private subscription: Subscription | null = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(
 | 
					  constructor(
 | 
				
			||||||
    @Inject(IAlbumRepository) private albumRepository: IAlbumRepository,
 | 
					    @Inject(IAlbumRepository) private albumRepository: IAlbumRepository,
 | 
				
			||||||
@ -81,10 +83,13 @@ export class MetadataService {
 | 
				
			|||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    this.configCore = SystemConfigCore.create(configRepository);
 | 
					    this.configCore = SystemConfigCore.create(configRepository);
 | 
				
			||||||
    this.storageCore = StorageCore.create(assetRepository, moveRepository, personRepository, storageRepository);
 | 
					    this.storageCore = StorageCore.create(assetRepository, moveRepository, personRepository, storageRepository);
 | 
				
			||||||
    this.configCore.config$.subscribe(() => this.init());
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  async init(deleteCache = false) {
 | 
					  async init(deleteCache = false) {
 | 
				
			||||||
 | 
					    if (!this.subscription) {
 | 
				
			||||||
 | 
					      this.subscription = this.configCore.config$.subscribe(() => this.init());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const { reverseGeocoding } = await this.configCore.getConfig();
 | 
					    const { reverseGeocoding } = await this.configCore.getConfig();
 | 
				
			||||||
    const { citiesFileOverride } = reverseGeocoding;
 | 
					    const { citiesFileOverride } = reverseGeocoding;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -111,6 +116,7 @@ export class MetadataService {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  async teardown() {
 | 
					  async teardown() {
 | 
				
			||||||
 | 
					    this.subscription?.unsubscribe();
 | 
				
			||||||
    await this.repository.teardown();
 | 
					    await this.repository.teardown();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,7 @@ export class CommunicationRepository implements OnGatewayConnection, OnGatewayDi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  constructor(private authService: AuthService) {}
 | 
					  constructor(private authService: AuthService) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @WebSocketServer() server!: Server;
 | 
					  @WebSocketServer() server?: Server;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  addEventListener(event: 'connect', callback: Callback) {
 | 
					  addEventListener(event: 'connect', callback: Callback) {
 | 
				
			||||||
    this.onConnectCallbacks.push(callback);
 | 
					    this.onConnectCallbacks.push(callback);
 | 
				
			||||||
@ -37,10 +37,10 @@ export class CommunicationRepository implements OnGatewayConnection, OnGatewayDi
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  send(event: CommunicationEvent, userId: string, data: any) {
 | 
					  send(event: CommunicationEvent, userId: string, data: any) {
 | 
				
			||||||
    this.server.to(userId).emit(event, data);
 | 
					    this.server?.to(userId).emit(event, data);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  broadcast(event: CommunicationEvent, data: any) {
 | 
					  broadcast(event: CommunicationEvent, data: any) {
 | 
				
			||||||
    this.server.emit(event, data);
 | 
					    this.server?.emit(event, data);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user