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
|
# Give the GUI thread a chance to do something. Python threads don't
|
||||||
# have priorities, so this thread would naturally keep the processor
|
# have priorities, so this thread would naturally keep the processor
|
||||||
# until some scheduling event happens. The sleep makes such an event
|
# until some scheduling event happens. The sleep makes such an event
|
||||||
print 'do one'
|
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
try:
|
try:
|
||||||
raw = metadata_to_opf(mi)
|
raw = metadata_to_opf(mi)
|
||||||
|
@ -145,25 +145,33 @@ class Restore(Thread):
|
|||||||
def create_cc_metadata(self):
|
def create_cc_metadata(self):
|
||||||
self.books.sort(key=itemgetter('timestamp'))
|
self.books.sort(key=itemgetter('timestamp'))
|
||||||
m = {}
|
m = {}
|
||||||
fields = ('label', 'name', 'datatype', 'is_multiple', 'editable',
|
fields = ('label', 'name', 'datatype', 'is_multiple', 'is_editable',
|
||||||
'display')
|
'display')
|
||||||
for b in self.books:
|
for b in self.books:
|
||||||
args = []
|
for key in b['mi'].custom_field_keys():
|
||||||
for x in fields:
|
cfm = b['mi'].metadata_for_field(key)
|
||||||
if x in b:
|
args = []
|
||||||
args.append(b[x])
|
for x in fields:
|
||||||
if len(args) == len(fields):
|
if x in cfm:
|
||||||
# TODO: Do series type columns need special handling?
|
if x == 'is_multiple':
|
||||||
label = b['label']
|
args.append(cfm[x] is not None)
|
||||||
if label in m and args != m[label]:
|
else:
|
||||||
if label not in self.conflicting_custom_cols:
|
args.append(cfm[x])
|
||||||
self.conflicting_custom_cols[label] = set([m[label]])
|
if len(args) == len(fields):
|
||||||
self.conflicting_custom_cols[label].add(args)
|
# TODO: Do series type columns need special handling?
|
||||||
m[b['label']] = args
|
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)
|
db = RestoreDatabase(self.library_path)
|
||||||
for args in m.values():
|
self.progress_callback(None, len(m))
|
||||||
db.create_custom_column(*args)
|
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()
|
db.conn.close()
|
||||||
|
|
||||||
def restore_books(self):
|
def restore_books(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user