mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix restoring custom column definitions
This commit is contained in:
parent
a05448f784
commit
10f9af93a9
@ -75,7 +75,6 @@ class MetadataBackup(Thread): # {{{
|
||||
# Give the GUI thread a chance to do something. Python threads don't
|
||||
# have priorities, so this thread would naturally keep the processor
|
||||
# until some scheduling event happens. The sleep makes such an event
|
||||
print 'do one'
|
||||
time.sleep(0.1)
|
||||
try:
|
||||
raw = metadata_to_opf(mi)
|
||||
|
@ -145,25 +145,33 @@ class Restore(Thread):
|
||||
def create_cc_metadata(self):
|
||||
self.books.sort(key=itemgetter('timestamp'))
|
||||
m = {}
|
||||
fields = ('label', 'name', 'datatype', 'is_multiple', 'editable',
|
||||
fields = ('label', 'name', 'datatype', 'is_multiple', 'is_editable',
|
||||
'display')
|
||||
for b in self.books:
|
||||
args = []
|
||||
for x in fields:
|
||||
if x in b:
|
||||
args.append(b[x])
|
||||
if len(args) == len(fields):
|
||||
# TODO: Do series type columns need special handling?
|
||||
label = b['label']
|
||||
if label in m and args != m[label]:
|
||||
if label not in self.conflicting_custom_cols:
|
||||
self.conflicting_custom_cols[label] = set([m[label]])
|
||||
self.conflicting_custom_cols[label].add(args)
|
||||
m[b['label']] = args
|
||||
for key in b['mi'].custom_field_keys():
|
||||
cfm = b['mi'].metadata_for_field(key)
|
||||
args = []
|
||||
for x in fields:
|
||||
if x in cfm:
|
||||
if x == 'is_multiple':
|
||||
args.append(cfm[x] is not None)
|
||||
else:
|
||||
args.append(cfm[x])
|
||||
if len(args) == len(fields):
|
||||
# TODO: Do series type columns need special handling?
|
||||
label = cfm['label']
|
||||
if label in m and args != m[label]:
|
||||
if label not in self.conflicting_custom_cols:
|
||||
self.conflicting_custom_cols[label] = set([m[label]])
|
||||
self.conflicting_custom_cols[label].add(args)
|
||||
m[cfm['label']] = args
|
||||
|
||||
db = RestoreDatabase(self.library_path)
|
||||
for args in m.values():
|
||||
db.create_custom_column(*args)
|
||||
self.progress_callback(None, len(m))
|
||||
if len(m):
|
||||
for i,args in enumerate(m.values()):
|
||||
db.create_custom_column(*args)
|
||||
self.progress_callback(_('creating custom column ')+args[0], i+1)
|
||||
db.conn.close()
|
||||
|
||||
def restore_books(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user