From 216cca43839d3b8e29ea3e3d0c022489e4922f7f Mon Sep 17 00:00:00 2001 From: Stephen Smith Date: Wed, 12 Jun 2024 06:43:38 -0400 Subject: [PATCH] fix(server): exiftool largefilesupport only set for the first call (#10167) * Revert "feat(server): enable exiftool largefilesupport (#9894)" This reverts commit afa10ebcb26d7c8f2518dd47b7106419b8012018. * feat(server): enable exiftool largefilesupport by passing options to read --- .../src/repositories/metadata.repository.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/server/src/repositories/metadata.repository.ts b/server/src/repositories/metadata.repository.ts index bbffb6aea7..0b32233f6a 100644 --- a/server/src/repositories/metadata.repository.ts +++ b/server/src/repositories/metadata.repository.ts @@ -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 { - 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 { - return this.exiftool.extractBinaryTagToBuffer(tagName, path); + return exiftool.extractBinaryTagToBuffer(tagName, path); } async writeTags(path: string, tags: Partial): Promise { 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}`); }