mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
DRYer
This commit is contained in:
parent
c7b4d8f979
commit
9cbb385b1c
@ -21,7 +21,7 @@ from queue import Queue
|
|||||||
from threading import Lock
|
from threading import Lock
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
|
|
||||||
from calibre import as_unicode, isbytestring
|
from calibre import as_unicode, isbytestring, detect_ncpus
|
||||||
from calibre.constants import iswindows, preferred_encoding
|
from calibre.constants import iswindows, preferred_encoding
|
||||||
from calibre.customize.ui import (
|
from calibre.customize.ui import (
|
||||||
run_plugins_on_import, run_plugins_on_postadd, run_plugins_on_postimport
|
run_plugins_on_import, run_plugins_on_postadd, run_plugins_on_postimport
|
||||||
@ -592,6 +592,15 @@ class Cache:
|
|||||||
self.queue_next_fts_job()
|
self.queue_next_fts_job()
|
||||||
return existing
|
return existing
|
||||||
|
|
||||||
|
@api
|
||||||
|
def set_fts_speed(self, slow=True):
|
||||||
|
if slow:
|
||||||
|
self.fts_indexing_sleep_time = Cache.fts_indexing_sleep_time
|
||||||
|
self.set_fts_num_of_workers(1)
|
||||||
|
else:
|
||||||
|
self.fts_indexing_sleep_time = 0.1
|
||||||
|
self.set_fts_num_of_workers(max(1, detect_ncpus()))
|
||||||
|
|
||||||
@read_api
|
@read_api
|
||||||
def fts_search(
|
def fts_search(
|
||||||
self,
|
self,
|
||||||
|
@ -8,8 +8,6 @@ from qt.core import (
|
|||||||
QRadioButton, QVBoxLayout, QWidget, pyqtSignal
|
QRadioButton, QVBoxLayout, QWidget, pyqtSignal
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import detect_ncpus
|
|
||||||
from calibre.db.cache import Cache
|
|
||||||
from calibre.db.listeners import EventType
|
from calibre.db.listeners import EventType
|
||||||
from calibre.db.utils import IndexingProgress
|
from calibre.db.utils import IndexingProgress
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
@ -71,12 +69,7 @@ class ScanProgress(QWidget):
|
|||||||
|
|
||||||
def change_speed(self):
|
def change_speed(self):
|
||||||
db = get_db()
|
db = get_db()
|
||||||
if self.fast_button.isChecked():
|
db.set_fts_speed(slow=not self.fast_button.isChecked())
|
||||||
db.fts_indexing_sleep_time = 0.1
|
|
||||||
db.set_fts_num_of_workers(max(1, detect_ncpus()))
|
|
||||||
else:
|
|
||||||
db.fts_indexing_sleep_time = Cache.fts_indexing_sleep_time
|
|
||||||
db.set_fts_num_of_workers(1)
|
|
||||||
self.indexing_progress.clear_rate_information()
|
self.indexing_progress.clear_rate_information()
|
||||||
|
|
||||||
def update(self, complete, left, total):
|
def update(self, complete, left, total):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user