From 61d86149ffde5838732ad492591284993769d75d Mon Sep 17 00:00:00 2001 From: root Date: Mon, 21 Nov 2022 17:19:56 +0300 Subject: [PATCH] calculate-utils: Fix cl-update-profile --- pym/update/utils/cl_update_profile.py | 4 ++-- pym/update/variables/update.py | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pym/update/utils/cl_update_profile.py b/pym/update/utils/cl_update_profile.py index ab7f5b3..e1948df 100644 --- a/pym/update/utils/cl_update_profile.py +++ b/pym/update/utils/cl_update_profile.py @@ -51,7 +51,7 @@ class ClUpdateProfileAction(Action): 'condition': lambda Get: not ( Get('cl_update_profile_storage').is_local( Get('cl_update_profile_url'), - Get('cl_update_profile_branch'))) + Get('cl_update_profile_branch'))) or Get('cl_update_profile_check_sync_allowed') }, {'name': 'reconfigure_vars1', 'method': 'Update.invalidateVariables("cl_update_profile_storage")', @@ -75,7 +75,7 @@ class ClUpdateProfileAction(Action): 'foreach': 'cl_update_profile_sync_rep', 'message': __("Syncing the {eachvar:capitalize} repository"), 'method': 'Update.syncRepositories(eachvar)', - 'condition': lambda Get: Get('cl_update_profile_check_sync') + 'condition': lambda Get: Get('cl_update_profile_check_sync_allowed') }, {'name': 'sync_reps:regen_cache', 'foreach': 'cl_update_sync_overlay_rep', diff --git a/pym/update/variables/update.py b/pym/update/variables/update.py index 7ae6a7e..4e41aef 100644 --- a/pym/update/variables/update.py +++ b/pym/update/variables/update.py @@ -27,7 +27,7 @@ from calculate.lib.datavars import (Variable, VariableError, SimpleDataVars, DataVarsError) from calculate.lib.utils.binhosts import (Binhosts, PackagesIndex, HOURS, BinhostSignError) -from calculate.lib.utils.files import readFile, listDirectory, process, pathJoin +from calculate.lib.utils.files import readFile, listDirectory, process, pathJoin, quite_unlink from calculate.lib.configparser import ConfigParser from calculate.lib.cl_lang import setLocalTranslate @@ -932,13 +932,22 @@ class VariableClUpdateProfileDependUrl(FieldValue, ReadonlyVariable): self.label = _("URL") -class VariableClUpdateProfileCheckSync(Variable): +class VariableClUpdateProfileCheckSyncAllowed(Variable): urls = 'cl_update_rep_url' names = 'cl_update_rep_name' + path = 'cl_update_profile_path' def get(self): if not self.Get(self.urls) or not self.Get(self.names): return False + repos = self.Get(self.path) + try: + for rep in repos: + with open(f'{rep}/test', 'w') as inf: + inf.write("test") + quite_unlink(f"{rep}/test") + except OSError: + return False return True