minor fixes
This commit is contained in:
parent
da99f6d138
commit
b0df94a4fa
4 changed files with 17 additions and 5 deletions
|
@ -461,14 +461,14 @@ class MetadataFetchHandler(private val context: Context) : MethodCallHandler {
|
|||
// * `context.getContentResolver().getType()` sometimes returns an incorrect value
|
||||
// * `MediaMetadataRetriever.setDataSource()` sometimes fails with `status = 0x80000000`
|
||||
// * file extension is unreliable
|
||||
// In the end, `metadata-extractor` is the most reliable, except for `tiff`/`dvd`/`mov` (false positives, false negatives),
|
||||
// In the end, `metadata-extractor` is the most reliable, except for `tiff`/`dvd`/`mov`/`zip` (false positives, false negatives),
|
||||
// in which case we trust the file extension
|
||||
// cf https://github.com/drewnoakes/metadata-extractor/issues/296
|
||||
if (path?.matches(TIFF_EXTENSION_PATTERN) == true) {
|
||||
metadataMap[KEY_MIME_TYPE] = MimeTypes.TIFF
|
||||
} else {
|
||||
dir.getSafeString(FileTypeDirectory.TAG_DETECTED_FILE_MIME_TYPE) {
|
||||
if (it != MimeTypes.TIFF && it != MimeTypes.DVD && it != MimeTypes.MOV) {
|
||||
if (it != MimeTypes.TIFF && it != MimeTypes.DVD && it != MimeTypes.MOV && it != MimeTypes.ZIP) {
|
||||
metadataMap[KEY_MIME_TYPE] = it
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ object MimeTypes {
|
|||
// vector
|
||||
const val SVG = "image/svg+xml"
|
||||
|
||||
// video
|
||||
private const val AVI = "video/avi"
|
||||
private const val AVI_VND = "video/vnd.avi"
|
||||
const val DVD = "video/dvd"
|
||||
|
@ -57,6 +58,9 @@ object MimeTypes {
|
|||
private const val OGV = "video/ogg"
|
||||
private const val WEBM = "video/webm"
|
||||
|
||||
// others
|
||||
const val ZIP = "application/zip"
|
||||
|
||||
fun isImage(mimeType: String?) = mimeType != null && mimeType.startsWith("image")
|
||||
|
||||
fun isVideo(mimeType: String?) = mimeType != null && mimeType.startsWith("video")
|
||||
|
|
|
@ -22,7 +22,9 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
|
|||
|
||||
final appliedModifier = await _applyDateModifierToEntry(userModifier);
|
||||
if (appliedModifier == null) {
|
||||
await reportService.recordError('failed to get date for modifier=$userModifier, entry=$this', null);
|
||||
if (!isMissingAtPath) {
|
||||
await reportService.recordError('failed to get date for modifier=$userModifier, entry=$this', null);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -374,7 +376,12 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
|
|||
switch (source) {
|
||||
case DateFieldSource.fileModifiedDate:
|
||||
try {
|
||||
date = path != null ? await File(path!).lastModified() : null;
|
||||
if (path != null) {
|
||||
final file = File(path!);
|
||||
if (await file.exists()) {
|
||||
date = await file.lastModified();
|
||||
}
|
||||
}
|
||||
} on FileSystemException catch (_) {}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -14,6 +14,7 @@ class MimeTypes {
|
|||
static const webp = 'image/webp';
|
||||
|
||||
static const art = 'image/x-jg';
|
||||
static const cdr = 'image/x-coreldraw';
|
||||
static const djvu = 'image/vnd.djvu';
|
||||
static const jxl = 'image/jxl';
|
||||
static const psdVnd = 'image/vnd.adobe.photoshop';
|
||||
|
@ -70,7 +71,7 @@ class MimeTypes {
|
|||
static const Set<String> rawImages = {arw, cr2, crw, dcr, dng, erf, k25, kdc, mrw, nef, nrw, orf, pef, raf, raw, rw2, sr2, srf, srw, x3f};
|
||||
|
||||
// TODO TLAD [codec] make it dynamic if it depends on OS/lib versions
|
||||
static const Set<String> undecodableImages = {art, crw, djvu, jxl, psdVnd, psdX, octetStream, zip};
|
||||
static const Set<String> undecodableImages = {art, cdr, crw, djvu, jxl, psdVnd, psdX, octetStream, zip};
|
||||
|
||||
static const Set<String> _knownOpaqueImages = {heic, heif, jpeg};
|
||||
|
||||
|
|
Loading…
Reference in a new issue