summaryrefslogtreecommitdiff
path: root/main/models.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-11-17 12:34:12 -0600
committerDan McGee <dan@archlinux.org>2011-11-17 12:49:10 -0600
commita9819e3d715ce3e5c20c9665db9a6100f06ab562 (patch)
tree0d5b457e7de06401095a17993735b1530f20f454 /main/models.py
parent9d2fdbe5bc6a0d9ab2907b377056851fc5eb56c3 (diff)
Ensure reporead is protected against simultaneous runs
This adds a bunch of transaction magic and SELECT FOR UPDATE stuff to reporead to cope with the now-concurrent runs of reporead we get when invoked from our inotify-based updater. The collision occurs with 'any' architecture packages as both repo databases contain the new version, and the updates occur at exactly the same time. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main/models.py')
-rw-r--r--main/models.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/main/models.py b/main/models.py
index caf36be0..cad4f9fc 100644
--- a/main/models.py
+++ b/main/models.py
@@ -159,7 +159,7 @@ class Package(models.Model):
on_delete=models.PROTECT)
arch = models.ForeignKey(Arch, related_name="packages",
on_delete=models.PROTECT)
- pkgname = models.CharField(max_length=255, db_index=True)
+ pkgname = models.CharField(max_length=255)
pkgbase = models.CharField(max_length=255, db_index=True)
pkgver = models.CharField(max_length=255)
pkgrel = models.CharField(max_length=255)
@@ -184,6 +184,7 @@ class Package(models.Model):
db_table = 'packages'
ordering = ('pkgname',)
get_latest_by = 'last_update'
+ unique_together = (('pkgname', 'repo', 'arch'),)
def __unicode__(self):
return self.pkgname