mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-05-09 05:21:13 +02:00
Fix for webservice problem with multi-chunk stories.
This commit is contained in:
parent
a28b8cb139
commit
df836412cc
1 changed files with 13 additions and 12 deletions
|
|
@ -210,18 +210,18 @@ class FileServer(webapp2.RequestHandler):
|
||||||
# to hold the whole in memory just for the
|
# to hold the whole in memory just for the
|
||||||
# compress/uncompress
|
# compress/uncompress
|
||||||
if download.format != 'epub':
|
if download.format != 'epub':
|
||||||
def dc(data):
|
def decompress(data):
|
||||||
try:
|
try:
|
||||||
return zlib.decompress(data)
|
return zlib.decompress(data)
|
||||||
# if error, assume it's a chunk from before we started compessing.
|
# if error, assume it's a chunk from before we started compessing.
|
||||||
except zlib.error:
|
except zlib.error:
|
||||||
return data
|
return data
|
||||||
else:
|
else:
|
||||||
def dc(data):
|
def decompress(data):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
for datum in data:
|
for datum in data:
|
||||||
self.response.out.write(dc(datum.blob))
|
self.response.out.write(decompress(datum.blob))
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
fic = DownloadMeta()
|
fic = DownloadMeta()
|
||||||
|
|
@ -286,8 +286,8 @@ class ClearRecentServer(webapp2.RequestHandler):
|
||||||
if results:
|
if results:
|
||||||
for d in results:
|
for d in results:
|
||||||
d.delete()
|
d.delete()
|
||||||
for c in d.data_chunks:
|
for chunk in d.data_chunks:
|
||||||
c.delete()
|
chunk.delete()
|
||||||
num = num + 1
|
num = num + 1
|
||||||
logging.debug('Delete '+d.url)
|
logging.debug('Delete '+d.url)
|
||||||
else:
|
else:
|
||||||
|
|
@ -494,8 +494,8 @@ class FanfictionDownloaderTask(UserConfigServer):
|
||||||
# use existing record if available.
|
# use existing record if available.
|
||||||
# fileId should have record from /fdown.
|
# fileId should have record from /fdown.
|
||||||
download = getDownloadMeta(id=fileId,url=url,user=user,format=format,new=True)
|
download = getDownloadMeta(id=fileId,url=url,user=user,format=format,new=True)
|
||||||
for c in download.data_chunks:
|
for chunk in download.data_chunks:
|
||||||
c.delete()
|
chunk.delete()
|
||||||
download.put()
|
download.put()
|
||||||
|
|
||||||
logging.info('Creating adapter...')
|
logging.info('Creating adapter...')
|
||||||
|
|
@ -542,21 +542,22 @@ class FanfictionDownloaderTask(UserConfigServer):
|
||||||
# compressed individually to avoid having to hold the
|
# compressed individually to avoid having to hold the
|
||||||
# whole in memory just for the compress/uncompress.
|
# whole in memory just for the compress/uncompress.
|
||||||
if format != 'epub':
|
if format != 'epub':
|
||||||
def c(data):
|
def compress(data):
|
||||||
return zlib.compress(data)
|
return zlib.compress(data)
|
||||||
else:
|
else:
|
||||||
def c(data):
|
def compress(data):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
# delete existing chunks first
|
# delete existing chunks first
|
||||||
for c in download.data_chunks:
|
for chunk in download.data_chunks:
|
||||||
c.delete()
|
chunk.delete()
|
||||||
|
|
||||||
index=0
|
index=0
|
||||||
while( len(data) > 0 ):
|
while( len(data) > 0 ):
|
||||||
|
# logging.info("len(data): %s" % len(data))
|
||||||
DownloadData(download=download,
|
DownloadData(download=download,
|
||||||
index=index,
|
index=index,
|
||||||
blob=c(data[:1000000])).put()
|
blob=compress(data[:1000000])).put()
|
||||||
index += 1
|
index += 1
|
||||||
data = data[1000000:]
|
data = data[1000000:]
|
||||||
download.completed=True
|
download.completed=True
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue