summaryrefslogtreecommitdiff
path: root/releng/models.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-01-28 23:56:30 -0600
committerDan McGee <dan@archlinux.org>2013-01-28 23:56:30 -0600
commit014b27b3920305455ac87f113ff95fad40991f21 (patch)
tree24044c766c02db5aa5ae3cbe41324ad055b44007 /releng/models.py
parent839371f3f8a7b6de199c48735098567db297928a (diff)
parent6cf98552f1c83d8e4fca1526131febd17045eae7 (diff)
Merge branch 'release'release_2013-01-28
Diffstat (limited to 'releng/models.py')
-rw-r--r--releng/models.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/releng/models.py b/releng/models.py
index a0dd57aa..b95f7d52 100644
--- a/releng/models.py
+++ b/releng/models.py
@@ -5,6 +5,7 @@ import hashlib
import markdown
from pytz import utc
+from django.conf import settings
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models.signals import pre_save
@@ -118,7 +119,9 @@ class Release(models.Model):
release_date = models.DateField(db_index=True)
version = models.CharField(max_length=50, unique=True)
kernel_version = models.CharField(max_length=50, blank=True)
- torrent_infohash = models.CharField(max_length=64, blank=True)
+ torrent_infohash = models.CharField(max_length=40, blank=True)
+ md5_sum = models.CharField('MD5 digest', max_length=32, blank=True)
+ sha1_sum = models.CharField('SHA1 digest', max_length=40, blank=True)
file_size = PositiveBigIntegerField(null=True, blank=True)
created = models.DateTimeField(editable=False)
available = models.BooleanField(default=True)
@@ -144,9 +147,9 @@ class Release(models.Model):
def magnet_uri(self):
query = [
('dn', "archlinux-%s-dual.iso" % self.version),
- ('tr', "udp://tracker.archlinux.org:6969"),
- ('tr', "http://tracker.archlinux.org:6969/announce"),
]
+ if settings.TORRENT_TRACKERS:
+ query.extend(('tr', uri) for uri in settings.TORRENT_TRACKERS)
if self.torrent_infohash:
query.insert(0, ('xt', "urn:btih:%s" % self.torrent_infohash))
return "magnet:?%s" % '&'.join(['%s=%s' % (k, v) for k, v in query])
@@ -160,6 +163,8 @@ class Release(models.Model):
data = b64decode(self.torrent_data)
except TypeError:
return None
+ if not data:
+ return None
data = bdecode(data)
# transform the data into a template-friendly dict
info = data.get('info', {})