Skip to content

Commit 959d387

Browse files
humitosericholscher
authored andcommitted
Save .cache path properly
+ refactor how cached directories are managed.
1 parent ff1df39 commit 959d387

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

readthedocs/projects/tasks.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,28 @@ def push_cached_environment(self):
136136
return
137137

138138
project_path = self.project.doc_path
139-
paths = [
140-
os.path.join(project_path, 'checkouts', self.version.slug),
141-
os.path.join(project_path, 'envs', self.version.slug),
142-
os.path.join(project_path, 'conda', self.version.slug),
143-
os.path.join(project_path, '.cache'),
139+
directories = [
140+
'checkouts',
141+
'envs',
142+
'conda',
144143
]
145144

146145
_, tmp_filename = tempfile.mkstemp(suffix='.tar')
147146
# open just with 'w', to not compress and waste CPU cycles
148147
with tarfile.open(tmp_filename, 'w') as tar:
149-
for path in paths:
148+
for directory in directories:
149+
path = os.path.join(
150+
project_path,
151+
directory,
152+
self.version.slug,
153+
)
154+
arcname = os.path.join(directory, self.version.slug)
150155
if os.path.exists(path):
151-
tar.add(
152-
path,
153-
arcname=os.path.join(
154-
os.path.basename(os.path.dirname(path)),
155-
self.version.slug,
156-
)
157-
)
156+
tar.add(path, arcname=arcname)
157+
158+
# Special handling for .cache directory because it's per-project
159+
path = os.path.join(project_path, '.cache')
160+
tar.add(path, arcname='.cache')
158161

159162
storage = get_storage_class(settings.RTD_BUILD_ENVIRONMENT_STORAGE)()
160163
with open(tmp_filename, 'rb') as fd:

0 commit comments

Comments
 (0)