mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-03-02 19:23:40 +01:00
Merge from trunk
This commit is contained in:
commit
f92fe67760
4 changed files with 16 additions and 11 deletions
|
|
@ -576,10 +576,15 @@ def parse_pml(self, pml, file_name=''):
|
|||
if indent_state[c]:
|
||||
basic_indent = True
|
||||
elif c == 'T':
|
||||
indent_state[c] = not indent_state[c]
|
||||
if indent_state[c]:
|
||||
# Ensure we only store the value on the first T set for the line.
|
||||
if not indent_state['T']:
|
||||
adv_indent = True
|
||||
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 == '-':
|
||||
empty = False
|
||||
text = '­'
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ def mark_dirty(self):
|
|||
db.dirtied(list(db.data.iterallids()))
|
||||
info_dialog(self.gui, _('Backup metadata'),
|
||||
_('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):
|
||||
db = self.gui.library_view.model().db
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
from itertools import repeat
|
||||
from datetime import timedelta
|
||||
from threading import Thread
|
||||
from Queue import Empty
|
||||
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.date import parse_date, now, UNDEFINED_DATE
|
||||
|
|
@ -54,7 +53,7 @@ def run(self):
|
|||
(id_, sequence) = self.db.get_a_dirtied_book()
|
||||
if id_ is None:
|
||||
continue
|
||||
print 'writer thread', id_, sequence
|
||||
# print 'writer thread', id_, sequence
|
||||
except:
|
||||
# Happens during interpreter shutdown
|
||||
break
|
||||
|
|
|
|||
|
|
@ -117,6 +117,9 @@ def exists_at(cls, path):
|
|||
def __init__(self, library_path, row_factory=False, default_prefs=None,
|
||||
read_only=False):
|
||||
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):
|
||||
os.makedirs(library_path)
|
||||
self.listeners = set([])
|
||||
|
|
@ -167,10 +170,6 @@ def get_property(self, idx, index_is_id=False, loc=-1):
|
|||
return row[loc]
|
||||
|
||||
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.prefs = DBPrefs(self)
|
||||
defs = self.prefs.defaults
|
||||
|
|
@ -624,6 +623,7 @@ def clear_dirtied(self, book_id, sequence):
|
|||
# print 'needs to be cleaned'
|
||||
self.conn.execute('DELETE FROM metadata_dirtied WHERE book=?',
|
||||
(book_id,))
|
||||
self.conn.commit()
|
||||
try:
|
||||
del self.dirtied_cache[book_id]
|
||||
except:
|
||||
|
|
@ -631,7 +631,6 @@ def clear_dirtied(self, book_id, sequence):
|
|||
elif dc_sequence is not None:
|
||||
# print 'book needs to be done again'
|
||||
pass
|
||||
self.conn.commit()
|
||||
|
||||
def dump_metadata(self, book_ids=None, remove_from_dirtied=True,
|
||||
commit=True):
|
||||
|
|
@ -659,6 +658,7 @@ def dump_metadata(self, book_ids=None, remove_from_dirtied=True,
|
|||
self.conn.commit()
|
||||
|
||||
def dirtied(self, book_ids, commit=True):
|
||||
changed = False
|
||||
for book in book_ids:
|
||||
with self.dirtied_lock:
|
||||
# print 'dirtied: check id', book
|
||||
|
|
@ -671,6 +671,7 @@ def dirtied(self, book_ids, commit=True):
|
|||
self.conn.execute(
|
||||
'INSERT INTO metadata_dirtied (book) VALUES (?)',
|
||||
(book,))
|
||||
changed = True
|
||||
except IntegrityError:
|
||||
# Already in table
|
||||
pass
|
||||
|
|
@ -680,7 +681,7 @@ def dirtied(self, book_ids, commit=True):
|
|||
# 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
|
||||
# back to the table on GUI exit. Not perfect, but probably OK
|
||||
if commit:
|
||||
if commit and changed:
|
||||
self.conn.commit()
|
||||
|
||||
def get_a_dirtied_book(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue