Skip to content

Commit 24ca737

Browse files
authored
Merge pull request #6799 from readthedocs/humitos/use-storage-properly-tar
Use storage.open API correctly for tar files (build cached envs)
2 parents b5bb99c + 657cbfc commit 24ca737

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

readthedocs/projects/tasks.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,9 @@ def pull_cached_environment(self):
119119
'msg': msg,
120120
}
121121
)
122-
_, tmp_filename = tempfile.mkstemp(suffix='.tar')
123122
remote_fd = storage.open(filename, mode='rb')
124-
with open(tmp_filename, mode='wb') as local_fd:
125-
local_fd.write(remote_fd.read())
126-
127-
with tarfile.open(tmp_filename) as tar:
128-
tar.extractall(self.version.project.doc_path)
129-
130-
# Cleanup the temporary file
131-
if os.path.exists(tmp_filename):
132-
os.remove(tmp_filename)
123+
with tarfile.open(fileobj=remote_fd) as tar:
124+
tar.extractall(self.project.doc_path)
133125

134126
def push_cached_environment(self):
135127
if not self.project.has_feature(feature_id=Feature.CACHED_ENVIRONMENT):

0 commit comments

Comments
 (0)