Skip to content

Commit

Permalink
Cache: purge rtd-addons when a new version is enabled & built
Browse files Browse the repository at this point in the history
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
  • Loading branch information
humitos committed Jul 22, 2024
1 parent bf02353 commit 3d09ba6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion readthedocs/projects/tasks/builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,18 @@ def get_valid_artifact_types(self):
def on_success(self, retval, task_id, args, kwargs):
valid_artifacts = self.get_valid_artifact_types()

# NOTE: we are updating the db version instance *only* when
# NOTE: we are updating the db version instance *only* if HTML build was successful
# TODO: remove this condition and *always* update the DB Version instance
if "html" in valid_artifacts:
if settings.READ_THE_DOCS_EXTENSIONS:
from readthedocsext.cdn.tasks import purge_tags

if not self.data.version.built:
# When the version was previously NOT built and now this build was successful,
# we purge the Addons API cache at this point.
# There is a new version that has to be shown in the flyout.
purge_tags.delay(["rtd-addons"])

try:
self.data.api_client.version(self.data.version.pk).patch(
{
Expand Down

0 comments on commit 3d09ba6

Please sign in to comment.