Large diffs are not rendered by default.

@@ -122,6 +122,7 @@ joblib = ">=0.15.1,<1.1.0"
sentry-sdk = ">=0.17.0,<1.3.0"
aio-pika = "^6.7.1"
pyTelegramBotAPI = "^3.7.3"
tarsafe = "^0.0.3"

[tool.poetry.dev-dependencies]
pytest-cov = "^2.10.0"
@@ -222,13 +222,14 @@ def unpack_model(
"""
import tarfile
from tarsafe import TarSafe

if working_directory is None:
working_directory = tempfile.mkdtemp()

# All files are in a subdirectory.
try:
with tarfile.open(model_file, mode="r:gz") as tar:
with TarSafe.open(model_file, mode="r:gz") as tar:
tar.extractall(working_directory)
logger.debug(f"Extracted model to '{working_directory}'.")
except (tarfile.TarError, ValueError) as e:
@@ -2,7 +2,7 @@
import logging
import os
import shutil
import tarfile
from tarsafe import TarSafe
from typing import Optional, Text, Tuple, TYPE_CHECKING

import rasa.shared.utils.common
@@ -103,7 +103,7 @@ def _tar_name(model_name: Text, include_extension: bool = True) -> Text:
@staticmethod
def _decompress(compressed_path: Text, target_path: Text) -> None:

with tarfile.open(compressed_path, "r:gz") as tar:
with TarSafe.open(compressed_path, "r:gz") as tar:
tar.extractall(target_path) # target dir will be created if it not exists


@@ -3,6 +3,7 @@
import os
import pickle
import tarfile
from tarsafe import TarSafe
import tempfile
import warnings
import zipfile
@@ -87,7 +88,7 @@ def unarchive(byte_array: bytes, directory: Text) -> Text:
Tries to use tar first to unpack, if that fails, zip will be used."""

try:
tar = tarfile.open(fileobj=IOReader(byte_array))
tar = TarSafe.open(fileobj=IOReader(byte_array))
tar.extractall(directory)
tar.close()
return directory