Update updater to handle venv folders

This commit is contained in:
Ozzieisaacs 2020-02-21 18:04:26 +01:00
parent ac431bbc4a
commit 3a70c86f49

View File

@ -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: