From cb7a9e3e712e9b42bc4d233f8b953425224ae7cd Mon Sep 17 00:00:00 2001 From: Zack Pollard Date: Tue, 16 Jul 2024 11:17:42 +0100 Subject: [PATCH] Revert "chore(server): update exiftool and migrate off deprecated method signatures (#10367)" This reverts commit 1b67ea2d --- e2e/test-assets | 2 +- server/package-lock.json | 15 +++---- server/package.json | 2 +- .../src/repositories/metadata.repository.ts | 43 ++++++++++--------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/e2e/test-assets b/e2e/test-assets index 625ec3a5e9aa9..e8a75d67e7099 160000 --- a/e2e/test-assets +++ b/e2e/test-assets @@ -1 +1 @@ -Subproject commit 625ec3a5e9aa9b087ad986e0c2e6a24edb4ea81e +Subproject commit e8a75d67e709935e3840802999fe6269fe5da912 diff --git a/server/package-lock.json b/server/package-lock.json index 9b8377bab0c63..cae7116cd653c 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -34,7 +34,7 @@ "class-transformer": "^0.5.1", "class-validator": "^0.14.0", "cookie-parser": "^1.4.6", - "exiftool-vendored": "~27.0.0", + "exiftool-vendored": "~26.2.0", "fast-glob": "^3.3.2", "fluent-ffmpeg": "^2.1.2", "geo-tz": "^8.0.0", @@ -9549,10 +9549,9 @@ } }, "node_modules/exiftool-vendored": { - "version": "27.0.0", - "resolved": "https://registry.npmjs.org/exiftool-vendored/-/exiftool-vendored-27.0.0.tgz", - "integrity": "sha512-/jHX8Jjadj0YJzpqnuBo1Yy2ln2hnRbBIc+3jcVOLQ6qhHEKsLRlfJ145Ghn7k/EcnfpDzVX3V8AUCTC8juTow==", - "license": "MIT", + "version": "26.2.0", + "resolved": "https://registry.npmjs.org/exiftool-vendored/-/exiftool-vendored-26.2.0.tgz", + "integrity": "sha512-7P6jQ944or7ic2SJzW+uaWK4TLDXlaCppHrBayl4MpIrVcEeQjiQTez4/oOH0wULIRu4j4H6Xruz4SLrDaafUg==", "dependencies": { "@photostructure/tz-lookup": "^10.0.0", "@types/luxon": "^3.4.2", @@ -23434,9 +23433,9 @@ } }, "exiftool-vendored": { - "version": "27.0.0", - "resolved": "https://registry.npmjs.org/exiftool-vendored/-/exiftool-vendored-27.0.0.tgz", - "integrity": "sha512-/jHX8Jjadj0YJzpqnuBo1Yy2ln2hnRbBIc+3jcVOLQ6qhHEKsLRlfJ145Ghn7k/EcnfpDzVX3V8AUCTC8juTow==", + "version": "26.2.0", + "resolved": "https://registry.npmjs.org/exiftool-vendored/-/exiftool-vendored-26.2.0.tgz", + "integrity": "sha512-7P6jQ944or7ic2SJzW+uaWK4TLDXlaCppHrBayl4MpIrVcEeQjiQTez4/oOH0wULIRu4j4H6Xruz4SLrDaafUg==", "requires": { "@photostructure/tz-lookup": "^10.0.0", "@types/luxon": "^3.4.2", diff --git a/server/package.json b/server/package.json index 86a4f7d08996a..be85f2947e807 100644 --- a/server/package.json +++ b/server/package.json @@ -60,7 +60,7 @@ "class-transformer": "^0.5.1", "class-validator": "^0.14.0", "cookie-parser": "^1.4.6", - "exiftool-vendored": "~27.0.0", + "exiftool-vendored": "~26.2.0", "fast-glob": "^3.3.2", "fluent-ffmpeg": "^2.1.2", "geo-tz": "^8.0.0", diff --git a/server/src/repositories/metadata.repository.ts b/server/src/repositories/metadata.repository.ts index dfb9f676c21ad..56b948208ad83 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 { InjectRepository } from '@nestjs/typeorm'; -import { 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'; @@ -17,39 +17,40 @@ export class MetadataRepository implements IMetadataRepository { @Inject(ILoggerRepository) private logger: ILoggerRepository, ) { this.logger.setContext(MetadataRepository.name); - this.exiftool = new ExifTool({ - defaultVideosToUTC: true, - backfillTimezones: true, - inferTimezoneFromDatestamps: true, - useMWG: true, - numericTags: [...DefaultReadTaskOptions.numericTags, 'FocalLength'], - /* eslint unicorn/no-array-callback-reference: off, unicorn/no-array-method-this-argument: off */ - geoTz: (lat, lon) => geotz.find(lat, lon)[0], - // Enable exiftool LFS to parse metadata for files larger than 2GB. - readArgs: ['-api', 'largefilesupport=1'], - writeArgs: ['-api', 'largefilesupport=1', '-overwrite_original'], - }); } - private exiftool: ExifTool; async teardown() { - await this.exiftool.end(); + await exiftool.end(); } readTags(path: string): Promise { - return this.exiftool.read(path).catch((error) => { - this.logger.warn(`Error reading exif data (${path}): ${error}`, error?.stack); - return null; - }) as Promise; + 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, + useMWG: true, + numericTags: [...DefaultReadTaskOptions.numericTags, 'FocalLength'], + /* eslint unicorn/no-array-callback-reference: off, unicorn/no-array-method-this-argument: off */ + geoTz: (lat, lon) => geotz.find(lat, lon)[0], + }) + .catch((error) => { + this.logger.warn(`Error reading exif data (${path}): ${error}`, error?.stack); + return null; + }) as Promise; } 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); + await exiftool.write(path, tags, ['-overwrite_original']); } catch (error) { this.logger.warn(`Error writing exif data (${path}): ${error}`); }