Skip to content

Commit

Permalink
Avoid purging release from CDN multiple times in single request
Browse files Browse the repository at this point in the history
In case several files are added, it's quite easy to hit CDN limits. Also
it makes no sense to fire several same purge requests at once.

Fixes phpmyadmin/phpmyadmin#13886

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed Jan 8, 2018
1 parent ae14a29 commit 2c265b4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions files/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class Release(models.Model):
snapshot = models.BooleanField(default=False, db_index=True)
date = models.DateTimeField(db_index=True, default=timezone.now)

purged = False

class Meta(object):
ordering = ['-version_num']

Expand Down Expand Up @@ -432,6 +434,9 @@ def dockerhub_trigger(tag):

@receiver(post_save, sender=Release)
def purge_release(sender, instance, **kwargs):
if instance.purged:
return
instance.purged = True
purge_cdn(
# Pages with _littleboxes.html
reverse('home'),
Expand Down

0 comments on commit 2c265b4

Please sign in to comment.