edit-meta: refactor datecheck
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/1010/head
parent
37881b36b4
commit
213a3d3778
|
@ -241,11 +241,15 @@ export default defineComponent({
|
||||||
|
|
||||||
// If a photo has no EXIF date header then updating the metadata will erase
|
// 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.
|
// the date taken. We need to prompt the user to keep the date taken.
|
||||||
|
const hasNoDate = (p: IPhoto) => {
|
||||||
|
const exif = p.imageInfo?.exif;
|
||||||
|
const hasExifDate = Boolean(exif?.DateTimeOriginal || exif?.CreateDate);
|
||||||
|
const isSettingDate = Boolean(exifs.get(p.fileid)!.AllDates);
|
||||||
|
return !hasExifDate && !isSettingDate;
|
||||||
|
};
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.photos!.some(
|
this.photos!.some(hasNoDate) &&
|
||||||
(p) =>
|
|
||||||
!p.imageInfo?.exif?.DateTimeOriginal && !p.imageInfo?.exif?.CreateDate && !exifs.get(p.fileid)!.AllDates,
|
|
||||||
) &&
|
|
||||||
(await utils.confirmDestructive({
|
(await utils.confirmDestructive({
|
||||||
title: this.t('memories', 'Missing date metadata'),
|
title: this.t('memories', 'Missing date metadata'),
|
||||||
message: this.t(
|
message: this.t(
|
||||||
|
@ -255,13 +259,13 @@ export default defineComponent({
|
||||||
}))
|
}))
|
||||||
) {
|
) {
|
||||||
for (const p of this.photos!) {
|
for (const p of this.photos!) {
|
||||||
// Check if we need / can update the date for this file
|
// Check if already has the date taken, or it if can't do anything
|
||||||
const raw = exifs.get(p.fileid)!;
|
if (!hasNoDate(p) || !p.datetaken) continue;
|
||||||
if (!p.datetaken || raw.AllDates) continue;
|
|
||||||
|
|
||||||
// Get the date in EXIF format
|
// Get the date in EXIF format
|
||||||
const dateTaken = utils.getExifDateStr(new Date(p.datetaken * 1000));
|
const dateTaken = utils.getExifDateStr(new Date(p.datetaken * 1000));
|
||||||
raw.AllDates = dateTaken;
|
const raw = exifs.get(p.fileid);
|
||||||
|
raw!.AllDates = dateTaken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue