mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB Output: More memory leak fixes when handling image collections. Also make custom float columns not normalized
This commit is contained in:
parent
d8f3c0605d
commit
da067aac7f
@ -21,7 +21,7 @@ class ANDROID(USBMS):
|
|||||||
0x0bb4 : { 0x0c02 : [0x100], 0x0c01 : [0x100]},
|
0x0bb4 : { 0x0c02 : [0x100], 0x0c01 : [0x100]},
|
||||||
|
|
||||||
# Motorola
|
# Motorola
|
||||||
0x22b8 : { 0x41d9 : [0x216], 0x2d67 : [0x100]},
|
0x22b8 : { 0x41d9 : [0x216], 0x2d67 : [0x100], 0x41db : [0x216]},
|
||||||
|
|
||||||
0x18d1 : { 0x4e11 : [0x0100, 0x226], 0x4e12: [0x0100, 0x226]},
|
0x18d1 : { 0x4e11 : [0x0100, 0x226], 0x4e12: [0x0100, 0x226]},
|
||||||
|
|
||||||
|
@ -1048,10 +1048,11 @@ class Manifest(object):
|
|||||||
self._data = None
|
self._data = None
|
||||||
return property(fget, fset, fdel, doc=doc)
|
return property(fget, fset, fdel, doc=doc)
|
||||||
|
|
||||||
def unload_data_from_memory(self):
|
def unload_data_from_memory(self, memory=None):
|
||||||
if isinstance(self._data, (str, bytes)):
|
if isinstance(self._data, (str, bytes)):
|
||||||
|
if memory is None:
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
pt = PersistentTemporaryFile('_oeb_base_mem_unloader')
|
pt = PersistentTemporaryFile(suffix='_oeb_base_mem_unloader.img')
|
||||||
pt.write(self._data)
|
pt.write(self._data)
|
||||||
pt.close()
|
pt.close()
|
||||||
def loader(*args):
|
def loader(*args):
|
||||||
@ -1060,6 +1061,12 @@ class Manifest(object):
|
|||||||
os.remove(pt.name)
|
os.remove(pt.name)
|
||||||
return ans
|
return ans
|
||||||
self._loader = loader
|
self._loader = loader
|
||||||
|
else:
|
||||||
|
def loader2(*args):
|
||||||
|
with open(memory, 'rb') as f:
|
||||||
|
ans = f.read()
|
||||||
|
return ans
|
||||||
|
self._loader = loader2
|
||||||
self._data = None
|
self._data = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,5 +48,6 @@ class OEBOutput(OutputFormatPlugin):
|
|||||||
os.makedirs(dir)
|
os.makedirs(dir)
|
||||||
with open(path, 'wb') as f:
|
with open(path, 'wb') as f:
|
||||||
f.write(str(item))
|
f.write(str(item))
|
||||||
|
item.unload_data_from_memory(memory=path)
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,8 +189,6 @@ class CustomColumns(object):
|
|||||||
if label is not None:
|
if label is not None:
|
||||||
self.conn.execute('UPDATE custom_columns SET label=? WHERE id=?',
|
self.conn.execute('UPDATE custom_columns SET label=? WHERE id=?',
|
||||||
(label, num))
|
(label, num))
|
||||||
self.custom_column_num_map[num]['label'] = label
|
|
||||||
self.custom_column_label_map[label] = self.custom_column_num_map[num]
|
|
||||||
changed = True
|
changed = True
|
||||||
if is_editable is not None:
|
if is_editable is not None:
|
||||||
self.conn.execute('UPDATE custom_columns SET is_editable=? WHERE id=?',
|
self.conn.execute('UPDATE custom_columns SET is_editable=? WHERE id=?',
|
||||||
@ -317,7 +315,8 @@ class CustomColumns(object):
|
|||||||
editable=True, display={}):
|
editable=True, display={}):
|
||||||
if datatype not in self.CUSTOM_DATA_TYPES:
|
if datatype not in self.CUSTOM_DATA_TYPES:
|
||||||
raise ValueError('%r is not a supported data type'%datatype)
|
raise ValueError('%r is not a supported data type'%datatype)
|
||||||
normalized = datatype not in ('datetime', 'comments', 'int', 'bool')
|
normalized = datatype not in ('datetime', 'comments', 'int', 'bool',
|
||||||
|
'float')
|
||||||
is_multiple = is_multiple and datatype in ('text',)
|
is_multiple = is_multiple and datatype in ('text',)
|
||||||
num = self.conn.execute(
|
num = self.conn.execute(
|
||||||
('INSERT INTO '
|
('INSERT INTO '
|
||||||
|
Loading…
x
Reference in New Issue
Block a user