Skip to content

Commit

Permalink
Hide extension check for Joe
Browse files Browse the repository at this point in the history
  • Loading branch information
battleoverflow committed Dec 18, 2023
1 parent f24f7b6 commit fb95529
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions sandboxapi/joe.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import json
import magic
import jbxapi
Expand Down Expand Up @@ -29,14 +30,15 @@ def analyze(self, handle, filename):
:return: Task ID as a string
"""

# If no file extension is present, we try to identify the file type as an extra precaution for Joe
try:
ext = mimetypes.guess_extension(magic.Magic(mime=True).from_file(filename)) or ".txt"
# If no file extension is present, we try to identify the file type as an extra precaution
# try:
# ext = mimetypes.guess_extension(magic.Magic(mime=True).from_file(handle.name)) or ".txt"

if ext and not filename.lower().endswith(ext):
filename = f"{filename}{ext}"
except FileNotFoundError as e:
pass
# if not os.path.splitext(handle.name)[-1].lower() and not handle.name.lower().endswith(ext):
# # Rename the file with the extension
# os.rename(handle.name, f"{handle.name}{ext}")
# except FileNotFoundError:
# pass

# ensure the handle is at offset 0.
handle.seek(0)
Expand Down

0 comments on commit fb95529

Please sign in to comment.