about summary refs log tree commit diff
path: root/gn3/fs_helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn3/fs_helpers.py')
-rw-r--r--gn3/fs_helpers.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/gn3/fs_helpers.py b/gn3/fs_helpers.py
index 73f6567..f313086 100644
--- a/gn3/fs_helpers.py
+++ b/gn3/fs_helpers.py
@@ -41,7 +41,7 @@ def get_dir_hash(directory: str) -> str:
 
 def jsonfile_to_dict(json_file: str) -> Dict:
     """Give a JSON_FILE, return a python dict"""
-    with open(json_file) as _file:
+    with open(json_file, encoding="utf-8") as _file:
         data = json.load(_file)
         return data
     raise FileNotFoundError
@@ -71,9 +71,8 @@ contents to TARGET_DIR/<dir-hash>.
             os.mkdir(os.path.join(target_dir, token))
         gzipped_file.save(tar_target_loc)
         # Extract to "tar_target_loc/token"
-        tar = tarfile.open(tar_target_loc)
-        tar.extractall(path=os.path.join(target_dir, token))
-        tar.close()
+        with tarfile.open(tar_target_loc) as tar:
+            tar.extractall(path=os.path.join(target_dir, token))
     # pylint: disable=W0703
     except Exception:
         return {"status": 128, "error": "gzip failed to unpack file"}