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)
|
r('enforce_cpu_limit', config, restart_required=True)
|
||||||
self.device_detection_button.clicked.connect(self.debug_device_detection)
|
self.device_detection_button.clicked.connect(self.debug_device_detection)
|
||||||
self.compact_button.clicked.connect(self.compact)
|
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_open_config_dir.clicked.connect(self.open_config_dir)
|
||||||
self.button_osx_symlinks.clicked.connect(self.create_symlinks)
|
self.button_osx_symlinks.clicked.connect(self.create_symlinks)
|
||||||
self.button_osx_symlinks.setVisible(isosx)
|
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):
|
def debug_device_detection(self, *args):
|
||||||
from calibre.gui2.preferences.device_debug import DebugDevice
|
from calibre.gui2.preferences.device_debug import DebugDevice
|
||||||
d = DebugDevice(self)
|
d = DebugDevice(self)
|
||||||
|
@ -124,7 +124,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<spacer name="verticalSpacer_9">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -132,7 +139,7 @@
|
|||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>18</height>
|
<height>1000</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
@ -44,6 +44,7 @@ class MetadataBackup(Thread): # {{{
|
|||||||
self.keep_running = False
|
self.keep_running = False
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
import traceback
|
||||||
while self.keep_running:
|
while self.keep_running:
|
||||||
try:
|
try:
|
||||||
time.sleep(0.5) # Limit to two per second
|
time.sleep(0.5) # Limit to two per second
|
||||||
@ -53,11 +54,11 @@ class MetadataBackup(Thread): # {{{
|
|||||||
except:
|
except:
|
||||||
# Happens during interpreter shutdown
|
# Happens during interpreter shutdown
|
||||||
break
|
break
|
||||||
|
|
||||||
try:
|
try:
|
||||||
path, mi = self.get_metadata_for_dump(id_)
|
path, mi = self.get_metadata_for_dump(id_)
|
||||||
except:
|
except:
|
||||||
prints('Failed to get backup metadata for id:', id_, 'once')
|
prints('Failed to get backup metadata for id:', id_, 'once')
|
||||||
import traceback
|
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
try:
|
try:
|
||||||
@ -67,6 +68,10 @@ class MetadataBackup(Thread): # {{{
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if mi is None:
|
||||||
|
self.clear_dirtied([id_])
|
||||||
|
continue
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -657,8 +657,11 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
self.dirtied(book_ids)
|
self.dirtied(book_ids)
|
||||||
|
|
||||||
def get_metadata_for_dump(self, idx):
|
def get_metadata_for_dump(self, idx):
|
||||||
path = os.path.join(self.abspath(idx, index_is_id=True), 'metadata.opf')
|
try:
|
||||||
mi = self.get_metadata(idx, index_is_id=True)
|
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))
|
return ((path, mi))
|
||||||
|
|
||||||
def get_metadata(self, idx, index_is_id=False, get_cover=False):
|
def get_metadata(self, idx, index_is_id=False, get_cover=False):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user