mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
f92fe67760
@ -576,10 +576,15 @@ class PML_HTMLizer(object):
|
|||||||
if indent_state[c]:
|
if indent_state[c]:
|
||||||
basic_indent = True
|
basic_indent = True
|
||||||
elif c == 'T':
|
elif c == 'T':
|
||||||
indent_state[c] = not indent_state[c]
|
# Ensure we only store the value on the first T set for the line.
|
||||||
if indent_state[c]:
|
if not indent_state['T']:
|
||||||
adv_indent = True
|
adv_indent = True
|
||||||
adv_indent_val = self.code_value(line)
|
adv_indent_val = self.code_value(line)
|
||||||
|
else:
|
||||||
|
# We detected a T previously on this line.
|
||||||
|
# Don't replace the first detected value.
|
||||||
|
self.code_value(line)
|
||||||
|
indent_state['T'] = True
|
||||||
elif c == '-':
|
elif c == '-':
|
||||||
empty = False
|
empty = False
|
||||||
text = '­'
|
text = '­'
|
||||||
|
@ -343,7 +343,7 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
db.dirtied(list(db.data.iterallids()))
|
db.dirtied(list(db.data.iterallids()))
|
||||||
info_dialog(self.gui, _('Backup metadata'),
|
info_dialog(self.gui, _('Backup metadata'),
|
||||||
_('Metadata will be backed up while calibre is running, at the '
|
_('Metadata will be backed up while calibre is running, at the '
|
||||||
'rate of approximately 1 book per second.'), show=True)
|
'rate of approximately 1 book every three seconds.'), show=True)
|
||||||
|
|
||||||
def check_library(self):
|
def check_library(self):
|
||||||
db = self.gui.library_view.model().db
|
db = self.gui.library_view.model().db
|
||||||
|
@ -10,7 +10,6 @@ import re, itertools, time, traceback
|
|||||||
from itertools import repeat
|
from itertools import repeat
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import Empty
|
|
||||||
|
|
||||||
from calibre.utils.config import tweaks
|
from calibre.utils.config import tweaks
|
||||||
from calibre.utils.date import parse_date, now, UNDEFINED_DATE
|
from calibre.utils.date import parse_date, now, UNDEFINED_DATE
|
||||||
@ -54,7 +53,7 @@ class MetadataBackup(Thread): # {{{
|
|||||||
(id_, sequence) = self.db.get_a_dirtied_book()
|
(id_, sequence) = self.db.get_a_dirtied_book()
|
||||||
if id_ is None:
|
if id_ is None:
|
||||||
continue
|
continue
|
||||||
print 'writer thread', id_, sequence
|
# print 'writer thread', id_, sequence
|
||||||
except:
|
except:
|
||||||
# Happens during interpreter shutdown
|
# Happens during interpreter shutdown
|
||||||
break
|
break
|
||||||
|
@ -117,6 +117,9 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
def __init__(self, library_path, row_factory=False, default_prefs=None,
|
def __init__(self, library_path, row_factory=False, default_prefs=None,
|
||||||
read_only=False):
|
read_only=False):
|
||||||
self.field_metadata = FieldMetadata()
|
self.field_metadata = FieldMetadata()
|
||||||
|
# Create the lock to be used to guard access to the metadata writer
|
||||||
|
# queues. This must be an RLock, not a Lock
|
||||||
|
self.dirtied_lock = threading.RLock()
|
||||||
if not os.path.exists(library_path):
|
if not os.path.exists(library_path):
|
||||||
os.makedirs(library_path)
|
os.makedirs(library_path)
|
||||||
self.listeners = set([])
|
self.listeners = set([])
|
||||||
@ -167,10 +170,6 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
return row[loc]
|
return row[loc]
|
||||||
|
|
||||||
def initialize_dynamic(self):
|
def initialize_dynamic(self):
|
||||||
# Create the lock to be used to guard access to the metadata writer
|
|
||||||
# queues. This must be an RLock, not a Lock
|
|
||||||
self.dirtied_lock = threading.RLock()
|
|
||||||
|
|
||||||
self.field_metadata = FieldMetadata() #Ensure we start with a clean copy
|
self.field_metadata = FieldMetadata() #Ensure we start with a clean copy
|
||||||
self.prefs = DBPrefs(self)
|
self.prefs = DBPrefs(self)
|
||||||
defs = self.prefs.defaults
|
defs = self.prefs.defaults
|
||||||
@ -624,6 +623,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
# print 'needs to be cleaned'
|
# print 'needs to be cleaned'
|
||||||
self.conn.execute('DELETE FROM metadata_dirtied WHERE book=?',
|
self.conn.execute('DELETE FROM metadata_dirtied WHERE book=?',
|
||||||
(book_id,))
|
(book_id,))
|
||||||
|
self.conn.commit()
|
||||||
try:
|
try:
|
||||||
del self.dirtied_cache[book_id]
|
del self.dirtied_cache[book_id]
|
||||||
except:
|
except:
|
||||||
@ -631,7 +631,6 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
elif dc_sequence is not None:
|
elif dc_sequence is not None:
|
||||||
# print 'book needs to be done again'
|
# print 'book needs to be done again'
|
||||||
pass
|
pass
|
||||||
self.conn.commit()
|
|
||||||
|
|
||||||
def dump_metadata(self, book_ids=None, remove_from_dirtied=True,
|
def dump_metadata(self, book_ids=None, remove_from_dirtied=True,
|
||||||
commit=True):
|
commit=True):
|
||||||
@ -659,6 +658,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
def dirtied(self, book_ids, commit=True):
|
def dirtied(self, book_ids, commit=True):
|
||||||
|
changed = False
|
||||||
for book in book_ids:
|
for book in book_ids:
|
||||||
with self.dirtied_lock:
|
with self.dirtied_lock:
|
||||||
# print 'dirtied: check id', book
|
# print 'dirtied: check id', book
|
||||||
@ -671,6 +671,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
self.conn.execute(
|
self.conn.execute(
|
||||||
'INSERT INTO metadata_dirtied (book) VALUES (?)',
|
'INSERT INTO metadata_dirtied (book) VALUES (?)',
|
||||||
(book,))
|
(book,))
|
||||||
|
changed = True
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
# Already in table
|
# Already in table
|
||||||
pass
|
pass
|
||||||
@ -680,7 +681,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
# could lead to a problem because on restart, we won't put the book back
|
# could lead to a problem because on restart, we won't put the book back
|
||||||
# into the dirtied_cache. We deal with this by writing the dirtied_cache
|
# into the dirtied_cache. We deal with this by writing the dirtied_cache
|
||||||
# back to the table on GUI exit. Not perfect, but probably OK
|
# back to the table on GUI exit. Not perfect, but probably OK
|
||||||
if commit:
|
if commit and changed:
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
def get_a_dirtied_book(self):
|
def get_a_dirtied_book(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user