mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-02 18:47:07 -05:00 
			
		
		
		
	fix(server): backup version checks not handling database versions correctly (#14102)
This commit is contained in:
		
							parent
							
								
									2f9019c0e1
								
							
						
					
					
						commit
						e17bd8efc6
					
				@ -149,7 +149,6 @@ describe(BackupService.name, () => {
 | 
				
			|||||||
      storageMock.unlink.mockResolvedValue();
 | 
					      storageMock.unlink.mockResolvedValue();
 | 
				
			||||||
      systemMock.get.mockResolvedValue(systemConfigStub.backupEnabled);
 | 
					      systemMock.get.mockResolvedValue(systemConfigStub.backupEnabled);
 | 
				
			||||||
      storageMock.createWriteStream.mockReturnValue(new PassThrough());
 | 
					      storageMock.createWriteStream.mockReturnValue(new PassThrough());
 | 
				
			||||||
      databaseMock.getPostgresVersion.mockResolvedValue('14.3.2');
 | 
					 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    it('should run a database backup successfully', async () => {
 | 
					    it('should run a database backup successfully', async () => {
 | 
				
			||||||
      const result = await sut.handleBackupDatabase();
 | 
					      const result = await sut.handleBackupDatabase();
 | 
				
			||||||
@ -199,7 +198,9 @@ describe(BackupService.name, () => {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
    it.each`
 | 
					    it.each`
 | 
				
			||||||
      postgresVersion                       | expectedVersion
 | 
					      postgresVersion                       | expectedVersion
 | 
				
			||||||
      ${'14.6.4'}     | ${14}
 | 
					      ${'14.10'}                            | ${14}
 | 
				
			||||||
 | 
					      ${'14.10.3'}                          | ${14}
 | 
				
			||||||
 | 
					      ${'14.10 (Debian 14.10-1.pgdg120+1)'} | ${14}
 | 
				
			||||||
      ${'15.3.3'}                           | ${15}
 | 
					      ${'15.3.3'}                           | ${15}
 | 
				
			||||||
      ${'16.4.2'}                           | ${16}
 | 
					      ${'16.4.2'}                           | ${16}
 | 
				
			||||||
      ${'17.15.1'}                          | ${17}
 | 
					      ${'17.15.1'}                          | ${17}
 | 
				
			||||||
 | 
				
			|||||||
@ -105,9 +105,8 @@ export class BackupService extends BaseService {
 | 
				
			|||||||
    const databaseVersion = await this.databaseRepository.getPostgresVersion();
 | 
					    const databaseVersion = await this.databaseRepository.getPostgresVersion();
 | 
				
			||||||
    const databaseSemver = semver.coerce(databaseVersion);
 | 
					    const databaseSemver = semver.coerce(databaseVersion);
 | 
				
			||||||
    const databaseMajorVersion = databaseSemver?.major;
 | 
					    const databaseMajorVersion = databaseSemver?.major;
 | 
				
			||||||
    const databaseSupported = semver.satisfies(databaseVersion, '>=14.0.0 <18.0.0');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!databaseMajorVersion || !databaseSupported) {
 | 
					    if (!databaseMajorVersion || !databaseSemver || !semver.satisfies(databaseSemver, '>=14.0.0 <18.0.0')) {
 | 
				
			||||||
      this.logger.error(`Database Backup Failure: Unsupported PostgreSQL version: ${databaseVersion}`);
 | 
					      this.logger.error(`Database Backup Failure: Unsupported PostgreSQL version: ${databaseVersion}`);
 | 
				
			||||||
      return JobStatus.FAILED;
 | 
					      return JobStatus.FAILED;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user