calculate-utils: Fix cl-update-profile

master 3.7.2.47
root 1 year ago
parent bf6b759bc2
commit 61d86149ff

@ -51,7 +51,7 @@ class ClUpdateProfileAction(Action):
'condition': lambda Get: not ( 'condition': lambda Get: not (
Get('cl_update_profile_storage').is_local( Get('cl_update_profile_storage').is_local(
Get('cl_update_profile_url'), 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', {'name': 'reconfigure_vars1',
'method': 'Update.invalidateVariables("cl_update_profile_storage")', 'method': 'Update.invalidateVariables("cl_update_profile_storage")',
@ -75,7 +75,7 @@ class ClUpdateProfileAction(Action):
'foreach': 'cl_update_profile_sync_rep', 'foreach': 'cl_update_profile_sync_rep',
'message': __("Syncing the {eachvar:capitalize} repository"), 'message': __("Syncing the {eachvar:capitalize} repository"),
'method': 'Update.syncRepositories(eachvar)', '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', {'name': 'sync_reps:regen_cache',
'foreach': 'cl_update_sync_overlay_rep', 'foreach': 'cl_update_sync_overlay_rep',

@ -27,7 +27,7 @@ from calculate.lib.datavars import (Variable, VariableError,
SimpleDataVars, DataVarsError) SimpleDataVars, DataVarsError)
from calculate.lib.utils.binhosts import (Binhosts, PackagesIndex, HOURS, from calculate.lib.utils.binhosts import (Binhosts, PackagesIndex, HOURS,
BinhostSignError) 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.configparser import ConfigParser
from calculate.lib.cl_lang import setLocalTranslate from calculate.lib.cl_lang import setLocalTranslate
@ -932,13 +932,22 @@ class VariableClUpdateProfileDependUrl(FieldValue, ReadonlyVariable):
self.label = _("URL") self.label = _("URL")
class VariableClUpdateProfileCheckSync(Variable): class VariableClUpdateProfileCheckSyncAllowed(Variable):
urls = 'cl_update_rep_url' urls = 'cl_update_rep_url'
names = 'cl_update_rep_name' names = 'cl_update_rep_name'
path = 'cl_update_profile_path'
def get(self): def get(self):
if not self.Get(self.urls) or not self.Get(self.names): if not self.Get(self.urls) or not self.Get(self.names):
return False 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 return True

Loading…
Cancel
Save