remove debug

This commit is contained in:
j 2014-04-11 19:17:46 +00:00
parent d6b5fa6993
commit 14315455da

View file

@ -13,15 +13,13 @@ class ChunkForm(forms.Form):
offset = forms.IntegerField(required=False) offset = forms.IntegerField(required=False)
done = forms.IntegerField(required=False) done = forms.IntegerField(required=False)
def save_chunk(self, file, chunk, offset, name, done_cb=None): def save_chunk(obj, file, chunk, offset, name, done_cb=None):
print 'file', file
print 'chunk', chunk
if not file: if not file:
file.name = name file.name = name
ox.makedirs(os.path.dirname(file.path)) ox.makedirs(os.path.dirname(file.path))
with open(file.path, 'w') as f: with open(file.path, 'w') as f:
f.write(chunk.read()) f.write(chunk.read())
self.save() obj.save()
else: else:
path = file.path path = file.path
size = file.size size = file.size
@ -34,14 +32,14 @@ def save_chunk(self, file, chunk, offset, name, done_cb=None):
f.write(chunk.read()) f.write(chunk.read())
return done_cb() if done_cb else True, file.size return done_cb() if done_cb else True, file.size
def process_chunk(request, _save_chunk): def process_chunk(request, save_chunk):
response = { response = {
'result': 1, 'result': 1,
} }
form = ChunkForm(request.POST, request.FILES) form = ChunkForm(request.POST, request.FILES)
if form.is_valid(): if form.is_valid():
d = form.cleaned_data d = form.cleaned_data
ok, _offset = _save_chunk(d['chunk'], d['offset'], d['done']) ok, _offset = save_chunk(d['chunk'], d['offset'], d['done'])
response['offset'] = _offset response['offset'] = _offset
response['result'] = 1 if ok else -1 response['result'] = 1 if ok else -1
if d['done']: if d['done']: