From 620caddd0eea68e135e54bdfc64cf3fa93fbbb4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20Kiss?= Date: Wed, 29 Jun 2022 09:21:27 +0200 Subject: [PATCH] Remove magic_file API We introduced this API to be able to use it ourselves, but as it turns out we don't need it, and we don't want to expose a public API unnecessarily, because we can never "take it back". Also the `MAGIC` environment variable works well for libmagic if someone wants to control the magic database, so this API might not even be needed. The problem we were trying to solve to use the same magic database on different systems, but that turned out impossible to do, because the magic database format breaks between every version, so the only way to use libmagic is to use the same version of the magic database, which is usually the one shipped with the system. --- unblob/processing.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/unblob/processing.py b/unblob/processing.py index 4e15d2dc28..0883b99d73 100644 --- a/unblob/processing.py +++ b/unblob/processing.py @@ -68,7 +68,6 @@ class ExtractionConfig: keep_extracted_chunks: bool = False extract_suffix: str = "_extract" handlers: Handlers = BUILTIN_HANDLERS - magic_file: Optional[Path] = None def get_extract_dir_for(self, path: Path) -> Path: """Extraction dir under root with the name of path.""" @@ -212,12 +211,8 @@ def __init__(self, config: ExtractionConfig): # By enabling keep_going (which eventually enables MAGIC_CONTINUE) all matching patterns # will be included in the magic string at the cost of being a bit slower, but increasing # accuracy by no shadowing rules. - self._get_magic = magic.Magic( - keep_going=True, magic_file=config.magic_file - ).from_file - self._get_mime_type = magic.Magic( - mime=True, magic_file=config.magic_file - ).from_file + self._get_magic = magic.Magic(keep_going=True).from_file + self._get_mime_type = magic.Magic(mime=True).from_file def process_task(self, task: Task) -> TaskResult: result = TaskResult(task)