Workaround for windows limitation when reading from network sockets. Should fix issues with large files in calibre libraries on network shares. Fixes #3248 (exception on saving book details)

This commit is contained in:
Kovid Goyal 2010-09-25 09:52:35 -06:00
parent b09e819422
commit b00e241477
2 changed files with 7 additions and 3 deletions

View File

@ -721,7 +721,13 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
path = self.format_abspath(index, format, index_is_id=index_is_id) path = self.format_abspath(index, format, index_is_id=index_is_id)
if path is not None: if path is not None:
f = open(path, mode) f = open(path, mode)
ret = f if as_file else f.read() try:
ret = f if as_file else f.read()
except IOError:
f.seek(0)
out = cStringIO.StringIO()
shutil.copyfileobj(f, out)
ret = out.getvalue()
if not as_file: if not as_file:
f.close() f.close()
return ret return ret

View File

@ -123,8 +123,6 @@ class ContentServer(object):
return self.static('index.html') return self.static('index.html')
# Actually get content from the database {{{ # Actually get content from the database {{{
def get_cover(self, id, thumbnail=False): def get_cover(self, id, thumbnail=False):
cover = self.db.cover(id, index_is_id=True, as_file=False) cover = self.db.cover(id, index_is_id=True, as_file=False)