Skip to content

Commit

Permalink
check if sidecarPath exists
Browse files Browse the repository at this point in the history
  • Loading branch information
JW-CH committed Jan 9, 2024
1 parent 8d0a619 commit 954a109
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion server/src/domain/metadata/metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ImmichLogger } from '@app/infra/logger';
import { Inject, Injectable } from '@nestjs/common';
import { ExifDateTime, Tags } from 'exiftool-vendored';
import { firstDateTime } from 'exiftool-vendored/dist/FirstDateTime';
import fs from 'fs';
import { constants } from 'fs/promises';
import _ from 'lodash';
import { Duration } from 'luxon';
Expand Down Expand Up @@ -431,7 +432,18 @@ export class MetadataService {
): Promise<{ exifData: ExifEntityWithoutGeocodeAndTypeOrm; tags: ImmichTags }> {
const stats = await this.storageRepository.stat(asset.originalPath);
const mediaTags = await this.repository.readTags(asset.originalPath);
const sidecarTags = asset.sidecarPath ? await this.repository.readTags(asset.sidecarPath) : null;

let sidecarTags = null;
if (asset.sidecarPath) {
// check if sidecar-file exists
if (fs.existsSync(asset.sidecarPath)) {
sidecarTags = await this.repository.readTags(asset.sidecarPath);
} else {
this.logger.error(
`Sidecar-File '${asset.sidecarPath}' for asset '${asset.id}' does not exist on the filesystem`,
);
}
}

// ensure date from sidecar is used if present
const hasDateOverride = !!this.getDateTimeOriginal(sidecarTags);
Expand Down

0 comments on commit 954a109

Please sign in to comment.