edit-metadata: prompt if no date

Signed-off-by: Varun Patil <radialapps@gmail.com>
dexie
Varun Patil 2023-10-01 10:28:45 -07:00
parent df07f8f671
commit a3f327ed36
2 changed files with 30 additions and 0 deletions

View File

@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
- **Feature**: Admin can now configure default behavior of loading high resolution image in viewer ([#672](https://github.com/pulsejet/memories/pull/672)) - **Feature**: Admin can now configure default behavior of loading high resolution image in viewer ([#672](https://github.com/pulsejet/memories/pull/672))
- **Feature**: Shared videos will now be transcoded to be smaller in size - **Feature**: Shared videos will now be transcoded to be smaller in size
- **Feature**: Confirmation box on deletion ([#798](https://github.com/pulsejet/memories/issues/798)) - **Feature**: Confirmation box on deletion ([#798](https://github.com/pulsejet/memories/issues/798))
- **Feature**: Prompt on editing metadata if date will be lost
- **Fix**: Support for transcoding MKV files. - **Fix**: Support for transcoding MKV files.
## [v5.4.1] - 2023-08-20 ## [v5.4.1] - 2023-08-20

View File

@ -195,6 +195,35 @@ export default defineComponent({
exifs.set(p.fileid, raw); exifs.set(p.fileid, raw);
} }
// If a photo has no EXIF date header then updating the metadata will erase
// the date taken. We need to prompt the user to keep the date taken.
if (
this.photos!.some(
(p) =>
!p.imageInfo?.exif?.DateTimeOriginal &&
!p.imageInfo?.exif?.CreateDate &&
!exifs.get(p.fileid)!.DateTimeOriginal
) &&
(await utils.confirmDestructive({
title: this.t('memories', 'Missing date metadata'),
message: this.t(
'memories',
'Some items may be missing the date metadata. Do you want to attempt copying the currently known timestamp to the metadata (recommended)? Othewise, the timestamp may be reset to the current time.'
),
}))
) {
for (const p of this.photos!) {
// Check if we need / can update the date for this file
const raw = exifs.get(p.fileid)!;
if (!p.datetaken || raw.DateTimeOriginal) continue;
// Get the date in EXIF format
const dateTaken = utils.getExifDateStr(new Date(p.datetaken * 1000));
raw.DateTimeOriginal = dateTaken;
raw.CreateDate = dateTaken;
}
}
// Update exif fields // Update exif fields
const calls = this.photos!.map((p) => async () => { const calls = this.photos!.map((p) => async () => {
let dirty = false; let dirty = false;