edit-meta: fail fast for forbidden mimes
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/900/head
parent
32e910561d
commit
3be478b8ce
|
@ -10,7 +10,7 @@ use OCP\Files\File;
|
|||
|
||||
class Exif
|
||||
{
|
||||
private const FORBIDDEN_EDIT_MIMES = ['image/bmp', 'image/x-dcraw', 'video/MP2T'];
|
||||
private const FORBIDDEN_EDIT_MIMES = ['image/bmp', 'image/x-dcraw', 'video/MP2T']; // also update const.ts
|
||||
private const EXIFTOOL_TIMEOUT = 30000;
|
||||
private const EXIFTOOL_ARGS = ['-api', 'QuickTimeUTC=1', '-n', '-json'];
|
||||
|
||||
|
|
|
@ -124,6 +124,18 @@ export default defineComponent({
|
|||
let done = 0;
|
||||
this.progress = 0;
|
||||
|
||||
// Filter out forbidden MIME types
|
||||
photos = photos.filter((p) => {
|
||||
if (this.c.FORBIDDEN_EDIT_MIMES.includes(p.mimetype ?? String())) {
|
||||
showWarning(
|
||||
this.t('memories', 'Cannot edit {name} of type {type}', { name: p.basename!, type: p.mimetype! }),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
// Load metadata for all photos
|
||||
const calls = photos.map((p) => async () => {
|
||||
try {
|
||||
|
|
|
@ -3,7 +3,6 @@ import type { IPhoto } from '@typings';
|
|||
|
||||
/** Global constants */
|
||||
export const constants = Object.freeze({
|
||||
// Flags for photos
|
||||
FLAG_PLACEHOLDER: 1 << 0,
|
||||
FLAG_LOAD_FAIL: 1 << 1,
|
||||
FLAG_IS_VIDEO: 1 << 2,
|
||||
|
@ -12,9 +11,10 @@ export const constants = Object.freeze({
|
|||
FLAG_LEAVING: 1 << 5,
|
||||
FLAG_IS_LOCAL: 1 << 6,
|
||||
|
||||
// Special strings
|
||||
FACE_NULL: 'NULL',
|
||||
|
||||
MIME_RAW: 'image/x-dcraw',
|
||||
FORBIDDEN_EDIT_MIMES: ['image/bmp', 'image/x-dcraw', 'video/MP2T'], // Exif.php
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue