1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-03-31 21:29:38 +02:00

feat(server): add path to metadata logging ()

feat(server): Prefer original path instead of id when logging
This commit is contained in:
Jonathan Jogenfors 2025-02-20 16:46:18 +01:00 committed by GitHub
parent 6b7a7b0cbc
commit f6ba071569
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -425,7 +425,7 @@ export class MetadataService extends BaseService {
return; return;
} }
this.logger.debug(`Starting motion photo video extraction (${asset.id})`); this.logger.debug(`Starting motion photo video extraction for asset ${asset.id}: ${asset.originalPath}`);
try { try {
const stat = await this.storageRepository.stat(asset.originalPath); const stat = await this.storageRepository.stat(asset.originalPath);
@ -457,9 +457,9 @@ export class MetadataService extends BaseService {
}); });
if (motionAsset) { if (motionAsset) {
this.logger.debug( this.logger.debug(
`Asset ${asset.id}'s motion photo video with checksum ${checksum.toString( `Motion photo video with checksum ${checksum.toString(
'base64', 'base64',
)} already exists in the repository`, )} already exists in the repository for asset ${asset.id}: ${asset.originalPath}`,
); );
// Hide the motion photo video asset if it's not already hidden to prepare for linking // Hide the motion photo video asset if it's not already hidden to prepare for linking
@ -516,9 +516,12 @@ export class MetadataService extends BaseService {
await this.jobRepository.queue({ name: JobName.METADATA_EXTRACTION, data: { id: motionAsset.id } }); await this.jobRepository.queue({ name: JobName.METADATA_EXTRACTION, data: { id: motionAsset.id } });
} }
this.logger.debug(`Finished motion photo video extraction (${asset.id})`); this.logger.debug(`Finished motion photo video extraction for asset ${asset.id}: ${asset.originalPath}`);
} catch (error: Error | any) { } catch (error: Error | any) {
this.logger.error(`Failed to extract live photo ${asset.originalPath}: ${error}`, error?.stack); this.logger.error(
`Failed to extract motion video for ${asset.id}: ${asset.originalPath}: ${error}`,
error?.stack,
);
} }
} }
@ -571,11 +574,13 @@ export class MetadataService extends BaseService {
const facesToRemove = asset.faces.filter((face) => face.sourceType === SourceType.EXIF).map((face) => face.id); const facesToRemove = asset.faces.filter((face) => face.sourceType === SourceType.EXIF).map((face) => face.id);
if (facesToRemove.length > 0) { if (facesToRemove.length > 0) {
this.logger.debug(`Removing ${facesToRemove.length} faces for asset ${asset.id}`); this.logger.debug(`Removing ${facesToRemove.length} faces for asset ${asset.id}: ${asset.originalPath}`);
} }
if (facesToAdd.length > 0) { if (facesToAdd.length > 0) {
this.logger.debug(`Creating ${facesToAdd.length} faces from metadata for asset ${asset.id}`); this.logger.debug(
`Creating ${facesToAdd.length} faces from metadata for asset ${asset.id}: ${asset.originalPath}`,
);
} }
if (facesToRemove.length > 0 || facesToAdd.length > 0) { if (facesToRemove.length > 0 || facesToAdd.length > 0) {
@ -589,7 +594,7 @@ export class MetadataService extends BaseService {
private getDates(asset: AssetEntity, exifTags: ImmichTags) { private getDates(asset: AssetEntity, exifTags: ImmichTags) {
const dateTime = firstDateTime(exifTags as Maybe<Tags>, EXIF_DATE_TAGS); const dateTime = firstDateTime(exifTags as Maybe<Tags>, EXIF_DATE_TAGS);
this.logger.verbose(`Asset ${asset.id} date time is ${dateTime}`); this.logger.verbose(`Date and time is ${dateTime} for asset ${asset.id}: ${asset.originalPath}`);
// timezone // timezone
let timeZone = exifTags.tz ?? null; let timeZone = exifTags.tz ?? null;
@ -600,23 +605,27 @@ export class MetadataService extends BaseService {
} }
if (timeZone) { if (timeZone) {
this.logger.verbose(`Asset ${asset.id} timezone is ${timeZone} (via ${exifTags.tzSource})`); this.logger.verbose(
`Found timezone ${timeZone} via ${exifTags.tzSource} for asset ${asset.id}: ${asset.originalPath}`,
);
} else { } else {
this.logger.debug(`Asset ${asset.id} has no time zone information`); this.logger.debug(`No timezone information found for asset ${asset.id}: ${asset.originalPath}`);
} }
let dateTimeOriginal = dateTime?.toDate(); let dateTimeOriginal = dateTime?.toDate();
let localDateTime = dateTime?.toDateTime().setZone('UTC', { keepLocalTime: true }).toJSDate(); let localDateTime = dateTime?.toDateTime().setZone('UTC', { keepLocalTime: true }).toJSDate();
if (!localDateTime || !dateTimeOriginal) { if (!localDateTime || !dateTimeOriginal) {
this.logger.debug( this.logger.debug(
`No valid date found in exif tags from asset ${asset.id}, falling back to earliest timestamp between file creation and file modification`, `No exif date time found, falling back on earliest of file creation and modification for assset ${asset.id}: ${asset.originalPath}`,
); );
const earliestDate = this.earliestDate(asset.fileModifiedAt, asset.fileCreatedAt); const earliestDate = this.earliestDate(asset.fileModifiedAt, asset.fileCreatedAt);
dateTimeOriginal = earliestDate; dateTimeOriginal = earliestDate;
localDateTime = earliestDate; localDateTime = earliestDate;
} }
this.logger.verbose(`Asset ${asset.id} has a local time of ${localDateTime.toISOString()}`); this.logger.verbose(
`Found local date time ${localDateTime.toISOString()} for asset ${asset.id}: ${asset.originalPath}`,
);
let modifyDate = asset.fileModifiedAt; let modifyDate = asset.fileModifiedAt;
try { try {
@ -754,6 +763,7 @@ export class MetadataService extends BaseService {
} }
if (sidecarPath) { if (sidecarPath) {
this.logger.debug(`Detected sidecar at '${sidecarPath}' for asset ${asset.id}: ${asset.originalPath}`);
await this.assetRepository.update({ id: asset.id, sidecarPath }); await this.assetRepository.update({ id: asset.id, sidecarPath });
return JobStatus.SUCCESS; return JobStatus.SUCCESS;
} }
@ -762,9 +772,7 @@ export class MetadataService extends BaseService {
return JobStatus.FAILED; return JobStatus.FAILED;
} }
this.logger.debug( this.logger.debug(`No sidecar found for asset ${asset.id}: ${asset.originalPath}`);
`Sidecar file was not found. Checked paths '${sidecarPathWithExt}' and '${sidecarPathWithoutExt}'. Removing sidecarPath for asset ${asset.id}`,
);
await this.assetRepository.update({ id: asset.id, sidecarPath: null }); await this.assetRepository.update({ id: asset.id, sidecarPath: null });
return JobStatus.SUCCESS; return JobStatus.SUCCESS;