mirror of
https://github.com/immich-app/immich.git
synced 2026-03-04 09:57:33 +03:00
feat(server): Support camera make, model, and lensModel in Storage Template (#24650)
* add support for make, model, lensModel in storage template * no pkg lock * Apply suggestion from @danieldietzler Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> * query and formatting --------- Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
e87bfa548a
commit
a16c5955d7
@@ -53,6 +53,7 @@ const storagePresets = [
|
||||
'{{y}}/{{y}}-{{MM}}/{{assetId}}',
|
||||
'{{y}}/{{y}}-{{WW}}/{{assetId}}',
|
||||
'{{album}}/{{filename}}',
|
||||
'{{make}}/{{model}}/{{lensModel}}/{{filename}}',
|
||||
];
|
||||
|
||||
export interface MoveAssetMetadata {
|
||||
@@ -67,6 +68,9 @@ interface RenderMetadata {
|
||||
albumName: string | null;
|
||||
albumStartDate: Date | null;
|
||||
albumEndDate: Date | null;
|
||||
make: string | null;
|
||||
model: string | null;
|
||||
lensModel: string | null;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
@@ -115,6 +119,9 @@ export class StorageTemplateService extends BaseService {
|
||||
albumName: 'album',
|
||||
albumStartDate: new Date(),
|
||||
albumEndDate: new Date(),
|
||||
make: 'FUJIFILM',
|
||||
model: 'X-T50',
|
||||
lensModel: 'XF27mm F2.8 R WR',
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.warn(`Storage template validation failed: ${JSON.stringify(error)}`);
|
||||
@@ -301,6 +308,9 @@ export class StorageTemplateService extends BaseService {
|
||||
albumName,
|
||||
albumStartDate,
|
||||
albumEndDate,
|
||||
make: asset.make,
|
||||
model: asset.model,
|
||||
lensModel: asset.lensModel,
|
||||
});
|
||||
const fullPath = path.normalize(path.join(rootPath, storagePath));
|
||||
let destination = `${fullPath}.${extension}`;
|
||||
@@ -365,7 +375,7 @@ export class StorageTemplateService extends BaseService {
|
||||
}
|
||||
|
||||
private render(template: HandlebarsTemplateDelegate<any>, options: RenderMetadata) {
|
||||
const { filename, extension, asset, albumName, albumStartDate, albumEndDate } = options;
|
||||
const { filename, extension, asset, albumName, albumStartDate, albumEndDate, make, model, lensModel } = options;
|
||||
const substitutions: Record<string, string> = {
|
||||
filename,
|
||||
ext: extension,
|
||||
@@ -375,6 +385,9 @@ export class StorageTemplateService extends BaseService {
|
||||
assetIdShort: asset.id.slice(-12),
|
||||
//just throw into the root if it doesn't belong to an album
|
||||
album: (albumName && sanitize(albumName.replaceAll(/\.+/g, ''))) || '',
|
||||
make: make ?? '',
|
||||
model: model ?? '',
|
||||
lensModel: lensModel ?? '',
|
||||
};
|
||||
|
||||
const systemTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
|
||||
Reference in New Issue
Block a user