From a968ddaef23eca781f70cc1c678ae7382dc7c2e4 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Thu, 28 Apr 2022 20:57:09 +0200 Subject: [PATCH] Bugfixes after testrun --- cps/__init__.py | 5 + cps/helper.py | 24 +- cps/main.py | 13 +- test/Calibre-Web TestSummary_Linux.html | 3103 +++++++++++++++-------- 4 files changed, 2112 insertions(+), 1033 deletions(-) diff --git a/cps/__init__.py b/cps/__init__.py index f597aab5..3f92571b 100644 --- a/cps/__init__.py +++ b/cps/__init__.py @@ -166,6 +166,11 @@ def create_app(): config.config_goodreads_api_secret, config.config_use_goodreads) config.store_calibre_uuid(calibre_db, db.Library_Id) + # Register scheduled tasks + from .schedule import register_scheduled_tasks, register_startup_tasks + register_scheduled_tasks(config.schedule_reconnect) + register_startup_tasks() + return app diff --git a/cps/helper.py b/cps/helper.py index 7c76d180..7362eb9e 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -342,9 +342,9 @@ def edit_book_read_status(book_id, read_status=None): return "" -# Deletes a book fro the local filestorage, returns True if deleting is successfull, otherwise false +# Deletes a book from the local filestorage, returns True if deleting is successful, otherwise false def delete_book_file(book, calibrepath, book_format=None): - # check that path is 2 elements deep, check that target path has no subfolders + # check that path is 2 elements deep, check that target path has no sub folders if book.path.count('/') == 1: path = os.path.join(calibrepath, book.path) if book_format: @@ -679,7 +679,8 @@ def update_dir_structure(book_id, def delete_book(book, calibrepath, book_format): - clear_cover_thumbnail_cache(book.id) + if not book_format: + clear_cover_thumbnail_cache(book.id) ## here it breaks if config.config_use_google_drive: return delete_book_gdrive(book, book_format) else: @@ -1003,21 +1004,26 @@ def get_download_link(book_id, book_format, client): def clear_cover_thumbnail_cache(book_id): - WorkerThread.add(None, TaskClearCoverThumbnailCache(book_id), hidden=True) + if config.schedule_generate_book_covers: + WorkerThread.add(None, TaskClearCoverThumbnailCache(book_id), hidden=True) def replace_cover_thumbnail_cache(book_id): - WorkerThread.add(None, TaskClearCoverThumbnailCache(book_id), hidden=True) - WorkerThread.add(None, TaskGenerateCoverThumbnails(book_id), hidden=True) + if config.schedule_generate_book_covers: + WorkerThread.add(None, TaskClearCoverThumbnailCache(book_id), hidden=True) + WorkerThread.add(None, TaskGenerateCoverThumbnails(book_id), hidden=True) def delete_thumbnail_cache(): - WorkerThread.add(None, TaskClearCoverThumbnailCache(-1)) + if config.schedule_generate_book_covers: + WorkerThread.add(None, TaskClearCoverThumbnailCache(-1)) def add_book_to_thumbnail_cache(book_id): - WorkerThread.add(None, TaskGenerateCoverThumbnails(book_id), hidden=True) + if config.schedule_generate_book_covers: + WorkerThread.add(None, TaskGenerateCoverThumbnails(book_id), hidden=True) def update_thumbnail_cache(): - WorkerThread.add(None, TaskGenerateCoverThumbnails()) + if config.schedule_generate_book_covers: + WorkerThread.add(None, TaskGenerateCoverThumbnails()) diff --git a/cps/main.py b/cps/main.py index ccf03c15..16d288ac 100644 --- a/cps/main.py +++ b/cps/main.py @@ -22,13 +22,6 @@ from . import create_app from .jinjia import jinjia from .remotelogin import remotelogin -try: - from kobo import kobo, get_kobo_activated - from kobo_auth import kobo_auth - kobo_available = get_kobo_activated() -except (ImportError, AttributeError): # Catch also error for not installed flask-WTF (missing csrf decorator) - kobo_available = False - try: from oauth_bb import oauth oauth_available = True @@ -50,6 +43,12 @@ def main(): from .shelf import shelf from .tasks_status import tasks from .error_handler import init_errorhandler + try: + from .kobo import kobo, get_kobo_activated + from .kobo_auth import kobo_auth + kobo_available = get_kobo_activated() + except (ImportError, AttributeError): # Catch also error for not installed flask-WTF (missing csrf decorator) + kobo_available = False from . import web_server init_errorhandler() diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index df55a037..cf3e893d 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
-

Start Time: 2022-04-25 20:37:58

+

Start Time: 2022-04-27 19:55:57

-

Stop Time: 2022-04-26 02:14:54

+

Stop Time: 2022-04-28 01:28:47

-

Duration: 4h 44 min

+

Duration: 4h 34 min

@@ -236,13 +236,13 @@ TestCli - 9 - 9 + 10 + 10 0 0 0 - Detail + Detail @@ -321,6 +321,15 @@ + +
TestCli - test_no_database
+ + PASS + + + + +
TestCli - test_settingsdb_not_writeable
@@ -332,13 +341,13 @@ TestCliGdrivedb - 3 - 3 + 4 + 4 0 0 0 - Detail + Detail @@ -370,6 +379,15 @@ + + + +
TestCliGdrivedb - test_no_database
+ + PASS + + + @@ -761,12 +779,12 @@ AssertionError: False is not true - + TestEditAdditionalBooks 17 - 10 - 2 - 4 + 16 + 0 + 0 1 Detail @@ -820,34 +838,11 @@ AssertionError: False is not true - +
TestEditAdditionalBooks - test_edit_book_identifier
- -
- FAIL -
- - - - + PASS @@ -861,31 +856,11 @@ AssertionError: 'Hallo1' != 'Hallo' - +
TestEditAdditionalBooks - test_edit_book_identifier_standard
- -
- FAIL -
- - - - + PASS @@ -926,70 +901,20 @@ AssertionError: 14 != 0 - +
TestEditAdditionalBooks - test_upload_metadata_cbr
- -
- ERROR -
- - - - + PASS - +
TestEditAdditionalBooks - test_upload_metadata_cbt
- -
- ERROR -
- - - - + PASS @@ -1003,145 +928,20 @@ element.find/</<@chrome://remote/content/marionette/element.js:300:16 +
TestEditAdditionalBooks - test_xss_comment_edit
- -
- ERROR -
- - - - + PASS - +
TestEditAdditionalBooks - test_xss_custom_comment_edit
- -
- ERROR -
- - - - - - - - - - - _ErrorHolder - 2 - 0 - 0 - 2 - 0 - - Detail - - - - - - - -
tearDownClass (test_edit_additional_books)
- - -
- ERROR -
- - - - - - - - - - -
setUpClass (test_thumbnail_env)
- - -
- ERROR -
- - - - + PASS @@ -1155,13 +955,13 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js 0 1 - Detail + Detail - +
TestEditBooks - test_download_book
@@ -1170,7 +970,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_author
@@ -1179,7 +979,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_category
@@ -1188,7 +988,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_comments
@@ -1197,7 +997,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_custom_bool
@@ -1206,7 +1006,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_custom_categories
@@ -1215,7 +1015,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_custom_comment
@@ -1224,7 +1024,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_custom_date
@@ -1233,7 +1033,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_custom_float
@@ -1242,7 +1042,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_custom_int
@@ -1251,7 +1051,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_custom_rating
@@ -1260,7 +1060,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_custom_single_select
@@ -1269,7 +1069,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_custom_text
@@ -1278,7 +1078,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_language
@@ -1287,7 +1087,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_publisher
@@ -1296,7 +1096,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_publishing_date
@@ -1305,7 +1105,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_rating
@@ -1314,7 +1114,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_series
@@ -1323,7 +1123,7 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_edit_title
@@ -1332,19 +1132,19 @@ AttributeError: type object 'TestThumbnailsEnv' has no attribute 'js - +
TestEditBooks - test_rename_uppercase_lowercase
- SKIP + SKIP
-