1
0
mirror of https://github.com/immich-app/immich.git synced 2025-01-01 11:37:06 +02:00

fix(server): exiftool largefilesupport only set for the first call (#10167)

* Revert "feat(server): enable exiftool largefilesupport (#9894)"

This reverts commit afa10ebcb2.

* feat(server): enable exiftool largefilesupport by passing options to read
This commit is contained in:
Stephen Smith 2024-06-12 06:43:38 -04:00 committed by GitHub
parent cdc98de848
commit 216cca4383
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,6 @@
import { Inject, Injectable } from '@nestjs/common';
import { InjectDataSource, InjectRepository } from '@nestjs/typeorm';
import { DefaultExiftoolArgs, DefaultReadTaskOptions, ExifTool, Tags } from 'exiftool-vendored';
import { DefaultReadTaskOptions, Tags, exiftool } from 'exiftool-vendored';
import geotz from 'geo-tz';
import { DummyValue, GenerateSql } from 'src/decorators';
import { ExifEntity } from 'src/entities/exif.entity';
@ -21,23 +21,18 @@ export class MetadataRepository implements IMetadataRepository {
) {
this.logger.setContext(MetadataRepository.name);
}
private exiftool: ExifTool = this.initExiftool();
async teardown() {
await this.exiftool.end();
}
private initExiftool() {
// Enable exiftool LFS to parse metadata for files larger than 2GB.
const exiftoolArgs = ['-api', 'largefilesupport=1', ...DefaultExiftoolArgs];
return new ExifTool({ exiftoolArgs });
await exiftool.end();
}
readTags(path: string): Promise<ImmichTags | null> {
return this.exiftool
return exiftool
.read(path, undefined, {
...DefaultReadTaskOptions,
// Enable exiftool LFS to parse metadata for files larger than 2GB.
optionalArgs: ['-api', 'largefilesupport=1'],
defaultVideosToUTC: true,
backfillTimezones: true,
inferTimezoneFromDatestamps: true,
@ -53,12 +48,12 @@ export class MetadataRepository implements IMetadataRepository {
}
extractBinaryTag(path: string, tagName: string): Promise<Buffer> {
return this.exiftool.extractBinaryTagToBuffer(tagName, path);
return exiftool.extractBinaryTagToBuffer(tagName, path);
}
async writeTags(path: string, tags: Partial<Tags>): Promise<void> {
try {
await this.exiftool.write(path, tags, ['-overwrite_original']);
await exiftool.write(path, tags, ['-overwrite_original']);
} catch (error) {
this.logger.warn(`Error writing exif data (${path}): ${error}`);
}