mirror of
https://github.com/fergalmoran/dss.api.git
synced 2026-01-06 08:33:57 +00:00
Updated some CDN urls
This commit is contained in:
22
spa/management/commands/tidy_cdn.py
Executable file
22
spa/management/commands/tidy_cdn.py
Executable file
@@ -0,0 +1,22 @@
|
||||
import os
|
||||
from django.core.management.base import NoArgsCommand
|
||||
from core.utils import cdn
|
||||
from spa.models import Mix
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
def handle_noargs(self, **options):
|
||||
try:
|
||||
print 'Enumerating items'
|
||||
items = cdn.enumerate_objects('mixes')
|
||||
for item in items:
|
||||
# Check if we have a corresponding mix
|
||||
uid, type = os.path.splitext(item)
|
||||
try:
|
||||
Mix.objects.get(uid=uid)
|
||||
except Mix.DoesNotExist:
|
||||
# no mix found - delete the blob
|
||||
cdn.delete_object('mixes', item)
|
||||
print "Deleting blob: {0}".format(uid)
|
||||
except Exception, ex:
|
||||
print "Debug exception: %s" % ex.message
|
||||
Reference in New Issue
Block a user