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]},
|
||||
|
||||
# Motorola
|
||||
0x22b8 : { 0x41d9 : [0x216], 0x2d67 : [0x100]},
|
||||
0x22b8 : { 0x41d9 : [0x216], 0x2d67 : [0x100], 0x41db : [0x216]},
|
||||
|
||||
0x18d1 : { 0x4e11 : [0x0100, 0x226], 0x4e12: [0x0100, 0x226]},
|
||||
|
||||
|
@ -1048,18 +1048,25 @@ class Manifest(object):
|
||||
self._data = None
|
||||
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)):
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
pt = PersistentTemporaryFile('_oeb_base_mem_unloader')
|
||||
pt.write(self._data)
|
||||
pt.close()
|
||||
def loader(*args):
|
||||
with open(pt.name, 'rb') as f:
|
||||
ans = f.read()
|
||||
os.remove(pt.name)
|
||||
return ans
|
||||
self._loader = loader
|
||||
if memory is None:
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
pt = PersistentTemporaryFile(suffix='_oeb_base_mem_unloader.img')
|
||||
pt.write(self._data)
|
||||
pt.close()
|
||||
def loader(*args):
|
||||
with open(pt.name, 'rb') as f:
|
||||
ans = f.read()
|
||||
os.remove(pt.name)
|
||||
return ans
|
||||
self._loader = loader
|
||||
else:
|
||||
def loader2(*args):
|
||||
with open(memory, 'rb') as f:
|
||||
ans = f.read()
|
||||
return ans
|
||||
self._loader = loader2
|
||||
self._data = None
|
||||
|
||||
|
||||
|
@ -48,5 +48,6 @@ class OEBOutput(OutputFormatPlugin):
|
||||
os.makedirs(dir)
|
||||
with open(path, 'wb') as f:
|
||||
f.write(str(item))
|
||||
item.unload_data_from_memory(memory=path)
|
||||
|
||||
|
||||
|
@ -189,8 +189,6 @@ class CustomColumns(object):
|
||||
if label is not None:
|
||||
self.conn.execute('UPDATE custom_columns SET label=? WHERE id=?',
|
||||
(label, num))
|
||||
self.custom_column_num_map[num]['label'] = label
|
||||
self.custom_column_label_map[label] = self.custom_column_num_map[num]
|
||||
changed = True
|
||||
if is_editable is not None:
|
||||
self.conn.execute('UPDATE custom_columns SET is_editable=? WHERE id=?',
|
||||
@ -317,7 +315,8 @@ class CustomColumns(object):
|
||||
editable=True, display={}):
|
||||
if datatype not in self.CUSTOM_DATA_TYPES:
|
||||
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',)
|
||||
num = self.conn.execute(
|
||||
('INSERT INTO '
|
||||
|
Loading…
x
Reference in New Issue
Block a user