From b7f3e00fbf36e5718be631c87004cdd005458782 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Fri, 21 Feb 2020 18:04:26 +0100 Subject: [PATCH] Update updater to handle venv folders --- cps/updater.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cps/updater.py b/cps/updater.py index 824e1314..9fe6e828 100644 --- a/cps/updater.py +++ b/cps/updater.py @@ -193,7 +193,12 @@ class Updater(threading.Thread): exclude = ( os.sep + 'app.db', os.sep + 'calibre-web.log1', os.sep + 'calibre-web.log2', os.sep + 'gdrive.db', os.sep + 'vendor', os.sep + 'calibre-web.log', os.sep + '.git', os.sep + 'client_secrets.json', - os.sep + 'gdrive_credentials', os.sep + 'settings.yaml') + os.sep + 'gdrive_credentials', os.sep + 'settings.yaml', os.sep + 'venv', os.sep + 'virtualenv', + os.sep + 'access.log', os.sep + 'access.log1', os.sep + 'access.log2', + ) + additional_path = self.is_venv() + if additional_path: + exclude = exclude + (additional_path) for root, dirs, files in os.walk(destination, topdown=True): for name in files: old_list.append(os.path.join(root, name).replace(destination, '')) @@ -229,6 +234,12 @@ class Updater(threading.Thread): logger.debug("Could not remove: %s", item_path) shutil.rmtree(source, ignore_errors=True) + def is_venv(self): + if (hasattr(sys, 'real_prefix')) or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix): + return os.sep + os.path.relpath(sys.prefix,constants.BASE_DIR) + else: + return False + @classmethod def _nightly_version_info(cls): if is_sha1(constants.NIGHTLY_VERSION[0]) and len(constants.NIGHTLY_VERSION[1]) > 0: