1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-10-31 15:16:20 +00:00

More fixes for googledrive

This commit is contained in:
Ozzieisaacs 2019-12-14 22:22:27 +01:00
parent e308a74dc2
commit 86fe970651
3 changed files with 15 additions and 2 deletions

View File

@ -170,6 +170,9 @@ def update_view_configuration():
_config_int("config_books_per_page")
_config_int("config_authors_max")
if config.config_google_drive_watch_changes_response:
config.config_google_drive_watch_changes_response = json.dumps(config.config_google_drive_watch_changes_response)
config.config_default_role = constants.selected_roles(to_save)
config.config_default_role &= ~constants.ROLE_ANONYMOUS
@ -258,6 +261,7 @@ def _configuration_update_helper():
db_change = False
to_save = request.form.to_dict()
# _config_dict = lambda x: config.set_from_dictionary(to_save, x, lambda y: y['id'])
_config_string = lambda x: config.set_from_dictionary(to_save, x, lambda y: y.strip() if y else y)
_config_int = lambda x: config.set_from_dictionary(to_save, x, int)
_config_checkbox = lambda x: config.set_from_dictionary(to_save, x, lambda y: y == "on", False)
@ -415,7 +419,8 @@ def _configuration_result(error_flash=None, gdriveError=None):
if gdriveError:
gdriveError = _(gdriveError)
else:
if config.config_use_google_drive and not gdrive_authenticate:
# if config.config_use_google_drive and\
if not gdrive_authenticate:
gdrivefolders = gdriveutils.listRootFolders()
show_back_button = current_user.is_authenticated

View File

@ -23,6 +23,7 @@
from __future__ import division, print_function, unicode_literals
import os
import sys
import hashlib
import json
import tempfile
@ -141,7 +142,10 @@ def on_received_watch_confirmation():
response = gdriveutils.getChangeById(gdriveutils.Gdrive.Instance().drive, j['id'])
log.debug('%r', response)
if response:
dbpath = os.path.join(config.config_calibre_dir, "metadata.db")
if sys.version_info < (3, 0):
dbpath = os.path.join(config.config_calibre_dir, "metadata.db")
else:
dbpath = os.path.join(config.config_calibre_dir, "metadata.db").encode()
if not response['deleted'] and response['file']['title'] == 'metadata.db' and response['file']['md5Checksum'] != hashlib.md5(dbpath):
tmpDir = tempfile.gettempdir()
log.info('Database file updated')

View File

@ -47,6 +47,10 @@ CREDENTIALS = os.path.join(_CONFIG_DIR, 'gdrive_credentials')
CLIENT_SECRETS = os.path.join(_CONFIG_DIR, 'client_secrets.json')
log = logger.create()
if gdrive_support:
logger.get('googleapiclient.discovery_cache').setLevel(logger.logging.ERROR)
if not logger.is_debug_enabled():
logger.get('googleapiclient.discovery').setLevel(logger.logging.ERROR)
class Singleton: