Skip to content

Commit a081a95

Browse files
committed
Fix order
1 parent 2d8290f commit a081a95

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

readthedocs/builds/forms.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ def clean_slug(self):
9999
return slug
100100

101101
def save(self, commit=True):
102-
obj = super().save(commit=commit)
103-
102+
# If the slug was changed, and the version was active,
103+
# we need to delete all the resources, since the old slug is used in several places.
104104
if "slug" in self.changed_data and self._was_active and self.instance.active:
105-
obj.recreate()
106-
return obj
105+
obj.clean_resources()
107106

107+
obj = super().save(commit=commit)
108108
obj.post_save(was_active=self._was_active)
109109
return obj
110110

readthedocs/builds/models.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ def clean_resources(self):
414414
clean_project_resources(project=self.project, version=self)
415415
self.built = False
416416
self.save()
417+
self.purge_cdn()
417418

418419
def post_save(self, was_active=False):
419420
"""
@@ -435,17 +436,17 @@ def post_save(self, was_active=False):
435436
# If the version is deactivated, we need to clean up the files.
436437
if was_active and not self.active:
437438
self.clean_resources()
439+
return
438440
# If the version is activated, we need to trigger a build.
439441
if not was_active and self.active:
440442
trigger_build(project=self.project, version=self)
441-
# Purge the cache from the CDN.
443+
# Purge the cache from the CDN for any other changes.
444+
self.purge_cdn()
445+
446+
def purge_cdn(self):
447+
"""Purge the cache from the CDN."""
442448
version_changed.send(sender=self.__class__, version=self)
443449

444-
def recreate(self):
445-
self.clean_resources()
446-
trigger_build(project=self.project, version=self)
447-
version_changed.send(sender=self.__class__, version=self)
448-
449450
@property
450451
def identifier_friendly(self):
451452
"""Return display friendly identifier."""

0 commit comments

Comments
 (0)