Flag for no coverage the really odd cases and the updated error handling in get_metadata
This commit is contained in:
parent
88a9c5079b
commit
dab86a0802
@ -71,7 +71,7 @@ def get_suggestion_cache(document_id: int) -> Optional[SuggestionCacheData]:
|
|||||||
and cache_hits[CLASSIFIER_HASH_KEY] == doc_suggestions.classifier_hash
|
and cache_hits[CLASSIFIER_HASH_KEY] == doc_suggestions.classifier_hash
|
||||||
):
|
):
|
||||||
return doc_suggestions
|
return doc_suggestions
|
||||||
else:
|
else: # pragma: no cover
|
||||||
# Remove the key because something didn't match
|
# Remove the key because something didn't match
|
||||||
cache.delete(doc_key)
|
cache.delete(doc_key)
|
||||||
return None
|
return None
|
||||||
@ -145,7 +145,7 @@ def get_metadata_cache(document_id: int) -> Optional[MetadataCacheData]:
|
|||||||
# Refresh cache
|
# Refresh cache
|
||||||
cache.touch(doc_key, CACHE_50_MINUTES)
|
cache.touch(doc_key, CACHE_50_MINUTES)
|
||||||
return doc_metadata
|
return doc_metadata
|
||||||
else:
|
else: # pragma: no cover
|
||||||
# Something didn't match, delete the key
|
# Something didn't match, delete the key
|
||||||
cache.delete(doc_key)
|
cache.delete(doc_key)
|
||||||
except Document.DoesNotExist: # pragma: no cover
|
except Document.DoesNotExist: # pragma: no cover
|
||||||
|
@ -389,11 +389,11 @@ class DocumentViewSet(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
return parser.extract_metadata(file, mime_type)
|
return parser.extract_metadata(file, mime_type)
|
||||||
except Exception:
|
except Exception: # pragma: no cover
|
||||||
logger.exception(f"Issue getting metadata for {file}")
|
logger.exception(f"Issue getting metadata for {file}")
|
||||||
# TODO: cover GPG errors, remove later.
|
# TODO: cover GPG errors, remove later.
|
||||||
return []
|
return []
|
||||||
else:
|
else: # pragma: no cover
|
||||||
logger.warning(f"No parser for {mime_type}")
|
logger.warning(f"No parser for {mime_type}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user