Skip to content

Commit

Permalink
fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed Jul 22, 2024
1 parent 564c4be commit a1d23ac
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ckanext/clamav/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _scan_filestream(file: FileStorage) -> tuple[str, Optional[str]]:
cd: Union[ClamdUnixSocket, ClamdNetworkSocket] = _get_conn()

try:
scan_result: dict[str, tuple[str, Optional[str]]] = cd.instream(file.stream)
scan_result: dict[str, tuple[str, str | None]] | None = cd.instream(file.stream)
except BufferTooLongError:
error_msg: str = (
"the uploaded file exceeds the filesize limit "
Expand All @@ -114,6 +114,9 @@ def _scan_filestream(file: FileStorage) -> tuple[str, Optional[str]]:
log.critical(error_msg)
return (c.CLAMAV_STATUS_ERR_DISABLED, error_msg)

if not scan_result:
return (c.CLAMAV_STATUS_ERR_DISABLED, None)

return scan_result["stream"]


Expand Down Expand Up @@ -150,7 +153,7 @@ def _get_conn() -> Union[ClamdUnixSocket, CustomClamdNetworkSocket]:
return ClamdUnixSocket(socket_path, conn_timeout)

tcp_host: str = tk.config.get(c.CLAMAV_CONF_SOCK_TCP_HOST)
tcp_port: str = tk.asint(tk.config.get(c.CLAMAV_CONF_SOCK_TCP_PORT))
tcp_port: int = tk.asint(tk.config.get(c.CLAMAV_CONF_SOCK_TCP_PORT))

if not all((tcp_port, tcp_host)):
raise CkanConfigurationException(
Expand Down

0 comments on commit a1d23ac

Please sign in to comment.