mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix problem trying to back up metadata for a deleted book
Add a 'backup all' button
This commit is contained in:
parent
88cb23d952
commit
1169eaef99
@ -88,10 +88,16 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
r('enforce_cpu_limit', config, restart_required=True)
|
||||
self.device_detection_button.clicked.connect(self.debug_device_detection)
|
||||
self.compact_button.clicked.connect(self.compact)
|
||||
self.button_all_books_dirty.clicked.connect(self.mark_dirty)
|
||||
self.button_open_config_dir.clicked.connect(self.open_config_dir)
|
||||
self.button_osx_symlinks.clicked.connect(self.create_symlinks)
|
||||
self.button_osx_symlinks.setVisible(isosx)
|
||||
|
||||
def mark_dirty(self):
|
||||
db = self.gui.library_view.model().db
|
||||
ids = [id for id in db.data.iterallids()]
|
||||
db.dirtied(ids)
|
||||
|
||||
def debug_device_detection(self, *args):
|
||||
from calibre.gui2.preferences.device_debug import DebugDevice
|
||||
d = DebugDevice(self)
|
||||
|
@ -124,7 +124,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<item row="10" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="button_all_books_dirty">
|
||||
<property name="text">
|
||||
<string>Force saving metadata of all books</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="20" column="0">
|
||||
<spacer name="verticalSpacer_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -132,7 +139,7 @@
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>18</height>
|
||||
<height>1000</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
@ -44,6 +44,7 @@ class MetadataBackup(Thread): # {{{
|
||||
self.keep_running = False
|
||||
|
||||
def run(self):
|
||||
import traceback
|
||||
while self.keep_running:
|
||||
try:
|
||||
time.sleep(0.5) # Limit to two per second
|
||||
@ -53,11 +54,11 @@ class MetadataBackup(Thread): # {{{
|
||||
except:
|
||||
# Happens during interpreter shutdown
|
||||
break
|
||||
|
||||
try:
|
||||
path, mi = self.get_metadata_for_dump(id_)
|
||||
except:
|
||||
prints('Failed to get backup metadata for id:', id_, 'once')
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
time.sleep(2)
|
||||
try:
|
||||
@ -67,6 +68,10 @@ class MetadataBackup(Thread): # {{{
|
||||
traceback.print_exc()
|
||||
continue
|
||||
|
||||
if mi is None:
|
||||
self.clear_dirtied([id_])
|
||||
continue
|
||||
|
||||
# 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
|
||||
|
@ -657,8 +657,11 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
self.dirtied(book_ids)
|
||||
|
||||
def get_metadata_for_dump(self, idx):
|
||||
try:
|
||||
path = os.path.join(self.abspath(idx, index_is_id=True), 'metadata.opf')
|
||||
mi = self.get_metadata(idx, index_is_id=True)
|
||||
except:
|
||||
return ((None, None))
|
||||
return ((path, mi))
|
||||
|
||||
def get_metadata(self, idx, index_is_id=False, get_cover=False):
|
||||
|
Loading…
x
Reference in New Issue
Block a user