Skip to content

Commit 620cadd

Browse files
committed
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.
1 parent e26dc7c commit 620cadd

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

unblob/processing.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class ExtractionConfig:
6868
keep_extracted_chunks: bool = False
6969
extract_suffix: str = "_extract"
7070
handlers: Handlers = BUILTIN_HANDLERS
71-
magic_file: Optional[Path] = None
7271

7372
def get_extract_dir_for(self, path: Path) -> Path:
7473
"""Extraction dir under root with the name of path."""
@@ -212,12 +211,8 @@ def __init__(self, config: ExtractionConfig):
212211
# By enabling keep_going (which eventually enables MAGIC_CONTINUE) all matching patterns
213212
# will be included in the magic string at the cost of being a bit slower, but increasing
214213
# accuracy by no shadowing rules.
215-
self._get_magic = magic.Magic(
216-
keep_going=True, magic_file=config.magic_file
217-
).from_file
218-
self._get_mime_type = magic.Magic(
219-
mime=True, magic_file=config.magic_file
220-
).from_file
214+
self._get_magic = magic.Magic(keep_going=True).from_file
215+
self._get_mime_type = magic.Magic(mime=True).from_file
221216

222217
def process_task(self, task: Task) -> TaskResult:
223218
result = TaskResult(task)

0 commit comments

Comments
 (0)