mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 12:15:47 -04:00
fix: retrieve version from lockfile and fallback to cli command (#17812)
This commit is contained in:
parent
be1062474b
commit
d2f2f8d672
@ -75,27 +75,49 @@ export class ServerInfoRepository {
|
|||||||
|
|
||||||
buildVersions?: ServerBuildVersions;
|
buildVersions?: ServerBuildVersions;
|
||||||
|
|
||||||
|
private async retrieveVersionFallback(
|
||||||
|
command: string,
|
||||||
|
commandTransform?: (output: string) => string,
|
||||||
|
version?: string,
|
||||||
|
): Promise<string> {
|
||||||
|
if (!version) {
|
||||||
|
const output = await maybeFirstLine(command);
|
||||||
|
version = commandTransform ? commandTransform(output) : output;
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
async getBuildVersions(): Promise<ServerBuildVersions> {
|
async getBuildVersions(): Promise<ServerBuildVersions> {
|
||||||
if (!this.buildVersions) {
|
if (!this.buildVersions) {
|
||||||
const { nodeVersion, resourcePaths } = this.configRepository.getEnv();
|
const { nodeVersion, resourcePaths } = this.configRepository.getEnv();
|
||||||
|
|
||||||
const [nodejsOutput, ffmpegOutput, magickOutput] = await Promise.all([
|
const lockfile: BuildLockfile | undefined = await readFile(resourcePaths.lockFile)
|
||||||
maybeFirstLine('node --version'),
|
|
||||||
maybeFirstLine('ffmpeg -version'),
|
|
||||||
maybeFirstLine('convert --version'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const lockfile = await readFile(resourcePaths.lockFile)
|
|
||||||
.then((buffer) => JSON.parse(buffer.toString()))
|
.then((buffer) => JSON.parse(buffer.toString()))
|
||||||
.catch(() => this.logger.warn(`Failed to read ${resourcePaths.lockFile}`));
|
.catch(() => this.logger.warn(`Failed to read ${resourcePaths.lockFile}`));
|
||||||
|
|
||||||
|
const [nodejsVersion, ffmpegVersion, magickVersion, exiftoolVersion] = await Promise.all([
|
||||||
|
this.retrieveVersionFallback('node --version', undefined, nodeVersion),
|
||||||
|
this.retrieveVersionFallback(
|
||||||
|
'ffmpeg -version',
|
||||||
|
(output) => output.replaceAll('ffmpeg version ', ''),
|
||||||
|
getLockfileVersion('ffmpeg', lockfile),
|
||||||
|
),
|
||||||
|
this.retrieveVersionFallback(
|
||||||
|
'magick --version',
|
||||||
|
(output) => output.replaceAll('Version: ImageMagick ', ''),
|
||||||
|
getLockfileVersion('imagemagick', lockfile),
|
||||||
|
),
|
||||||
|
exiftool.version(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const libvipsVersion = getLockfileVersion('libvips', lockfile) || sharp.versions.vips;
|
||||||
|
|
||||||
this.buildVersions = {
|
this.buildVersions = {
|
||||||
nodejs: nodejsOutput || nodeVersion || '',
|
nodejs: nodejsVersion,
|
||||||
exiftool: await exiftool.version(),
|
exiftool: exiftoolVersion,
|
||||||
ffmpeg: getLockfileVersion('ffmpeg', lockfile) || ffmpegOutput.replaceAll('ffmpeg version', '') || '',
|
ffmpeg: ffmpegVersion,
|
||||||
libvips: getLockfileVersion('libvips', lockfile) || sharp.versions.vips,
|
libvips: libvipsVersion,
|
||||||
imagemagick:
|
imagemagick: magickVersion,
|
||||||
getLockfileVersion('imagemagick', lockfile) || magickOutput.replaceAll('Version: ImageMagick ', '') || '',
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user