minor fix
This commit is contained in:
parent
7c81b4bbfc
commit
d04cb12e00
1 changed files with 7 additions and 5 deletions
|
@ -38,11 +38,6 @@ internal class ContentImageProvider : ImageProvider() {
|
|||
}
|
||||
|
||||
val mimeType = extractorMimeType ?: sourceMimeType
|
||||
if (mimeType == null) {
|
||||
callback.onFailure(Exception("MIME type is null for uri=$uri"))
|
||||
return
|
||||
}
|
||||
|
||||
val fields: FieldMap = hashMapOf(
|
||||
"origin" to SourceEntry.ORIGIN_UNKNOWN_CONTENT,
|
||||
"uri" to uri.toString(),
|
||||
|
@ -57,6 +52,8 @@ internal class ContentImageProvider : ImageProvider() {
|
|||
cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME).let { if (it != -1) fields["title"] = cursor.getString(it) }
|
||||
cursor.getColumnIndex(OpenableColumns.SIZE).let { if (it != -1) fields["sizeBytes"] = cursor.getLong(it) }
|
||||
cursor.getColumnIndex(MediaStore.MediaColumns.DATA).let { if (it != -1) fields["path"] = cursor.getString(it) }
|
||||
// mime type fallback if it was not provided and not found via `metadata-extractor`
|
||||
cursor.getColumnIndex(MediaStore.MediaColumns.MIME_TYPE).let { if (it != -1 && mimeType == null) fields["sourceMimeType"] = cursor.getString(it) }
|
||||
cursor.close()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
@ -64,6 +61,11 @@ internal class ContentImageProvider : ImageProvider() {
|
|||
return
|
||||
}
|
||||
|
||||
if (fields["sourceMimeType"] == null) {
|
||||
callback.onFailure(Exception("Failed to find MIME type for uri=$uri"))
|
||||
return
|
||||
}
|
||||
|
||||
val entry = SourceEntry(fields).fillPreCatalogMetadata(context)
|
||||
if (entry.isSized || entry.isSvg || entry.isVideo) {
|
||||
callback.onSuccess(entry.toMap())
|
||||
|
|
Loading…
Reference in a new issue