Skip to content

Commit

Permalink
Fix for janeczku#3131 (Enable/Disable "Separate Book Files from Libra…
Browse files Browse the repository at this point in the history
…ry" issue)
  • Loading branch information
OzzieIsaacs committed Aug 23, 2024
1 parent 5e9dfc0 commit 481237d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
9 changes: 7 additions & 2 deletions cps/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,13 @@ def _db_configuration_update_helper():
db_change = True
except Exception as ex:
return _db_configuration_result('{}'.format(ex), gdrive_error)
config.config_calibre_split = to_save.get('config_calibre_split', 0) == "on"
if config.config_calibre_split:
split_dir = to_save.get("config_calibre_split_dir")
if not os.path.exists(split_dir):
return _db_configuration_result(_("Books path not valid"), gdrive_error)
else:
_config_string(to_save, "config_calibre_split_dir")

if db_change or not db_valid or not config.db_configured \
or config.config_calibre_dir != to_save["config_calibre_dir"]:
Expand All @@ -1741,8 +1748,6 @@ def _db_configuration_update_helper():
calibre_db.update_config(config)
if not os.access(os.path.join(config.config_calibre_dir, "metadata.db"), os.W_OK):
flash(_("DB is not Writeable"), category="warning")
_config_string(to_save, "config_calibre_split_dir")
config.config_calibre_split = to_save.get('config_calibre_split', 0) == "on"
calibre_db.update_config(config)
config.save()
return _db_configuration_result(None, gdrive_error)
Expand Down
20 changes: 0 additions & 20 deletions cps/config_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,26 +182,6 @@ def __repr__(self):
class ConfigSQL(object):
# pylint: disable=no-member
def __init__(self):
'''self.config_calibre_uuid = None
self.config_calibre_split_dir = None
self.dirty = None
self.config_logfile = None
self.config_upload_formats = None
self.mail_gmail_token = None
self.mail_server_type = None
self.mail_server = None
self.config_log_level = None
self.config_allowed_column_value = None
self.config_denied_column_value = None
self.config_allowed_tags = None
self.config_denied_tags = None
self.config_default_show = None
self.config_default_role = None
self.config_keyfile = None
self.config_certfile = None
self.config_rarfile_location = None
self.config_kepubifypath = None
self.config_binariesdir = None'''
self.__dict__["dirty"] = list()

def init_config(self, session, secret_key, cli):
Expand Down
4 changes: 1 addition & 3 deletions cps/embed_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ def do_calibre_export(book_id, book_format):
my_env = os.environ.copy()
if config.config_calibre_split:
my_env['CALIBRE_OVERRIDE_DATABASE_PATH'] = os.path.join(config.config_calibre_dir, "metadata.db")
library_path = config.config_calibre_split_dir
else:
library_path = config.config_calibre_dir
library_path = config.get_book_path()
opf_command = [calibredb_binarypath, 'export', '--dont-write-opf', '--with-library', library_path,
'--to-dir', tmp_dir, '--formats', book_format, "--template", "{}".format(temp_file_name),
str(book_id)]
Expand Down

0 comments on commit 481237d

Please sign in to comment.