Skip to content

Commit 3d09ba6

Browse files
committed
Cache: purge rtd-addons when a new version is enabled & built
Note that I wasn't able to write a test case because `readthedocsext` is not installed in our test suite, so I cannot check this task is called. Closes #11291
1 parent bf02353 commit 3d09ba6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

readthedocs/projects/tasks/builds.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -650,9 +650,18 @@ def get_valid_artifact_types(self):
650650
def on_success(self, retval, task_id, args, kwargs):
651651
valid_artifacts = self.get_valid_artifact_types()
652652

653-
# NOTE: we are updating the db version instance *only* when
653+
# NOTE: we are updating the db version instance *only* if HTML build was successful
654654
# TODO: remove this condition and *always* update the DB Version instance
655655
if "html" in valid_artifacts:
656+
if settings.READ_THE_DOCS_EXTENSIONS:
657+
from readthedocsext.cdn.tasks import purge_tags
658+
659+
if not self.data.version.built:
660+
# When the version was previously NOT built and now this build was successful,
661+
# we purge the Addons API cache at this point.
662+
# There is a new version that has to be shown in the flyout.
663+
purge_tags.delay(["rtd-addons"])
664+
656665
try:
657666
self.data.api_client.version(self.data.version.pk).patch(
658667
{

0 commit comments

Comments
 (0)