cleanup file state

This commit is contained in:
j 2011-08-26 17:52:08 +02:00
parent 56b292619d
commit c54f47590b
2 changed files with 2 additions and 4 deletions

View file

@ -154,7 +154,8 @@ class File(models.Model):
if self.is_subtitle: if self.is_subtitle:
self.available = self.data and True or False self.available = self.data and True or False
else: else:
self.available = self.streams.filter(source=None, available=True).count() > 0 self.available = not self.uploading and \
self.streams.filter(source=None, available=True).count() > 0
super(File, self).save(*args, **kwargs) super(File, self).save(*args, **kwargs)
#upload and data handling #upload and data handling

View file

@ -153,7 +153,6 @@ def upload(request):
if f.data: if f.data:
f.data.delete() f.data.delete()
f.data.save('data.raw', request.FILES['file']) f.data.save('data.raw', request.FILES['file'])
f.available = True
f.save() f.save()
item.tasks.load_subtitles.delay(f.item.itemId) item.tasks.load_subtitles.delay(f.item.itemId)
response = json_response(text='file saved') response = json_response(text='file saved')
@ -192,7 +191,6 @@ def firefogg_upload(request):
if not f.save_chunk(c, chunk_id, form.cleaned_data['done']): if not f.save_chunk(c, chunk_id, form.cleaned_data['done']):
response['result'] = -1 response['result'] = -1
elif form.cleaned_data['done']: elif form.cleaned_data['done']:
f.available = True
f.uploading = False f.uploading = False
f.save() f.save()
#FIXME: this fails badly if rabbitmq goes down #FIXME: this fails badly if rabbitmq goes down
@ -210,7 +208,6 @@ def firefogg_upload(request):
f = get_object_or_404(models.File, oshash=oshash) f = get_object_or_404(models.File, oshash=oshash)
if f.editable(request.user): if f.editable(request.user):
f.streams.all().delete() f.streams.all().delete()
f.available = False
f.uploading = True f.uploading = True
f.save() f.save()
response = { response = {