Добавлено скачивание Packages если он отсутствует или у него не тот TTL

master-3.5
parent 2fbafa7f68
commit d26c91369e

@ -280,7 +280,7 @@ class ClUpdateAction(Action):
"eix_update")), "eix_update")),
} }
] ]
}, },
{'name': 'reps_synchronization', {'name': 'reps_synchronization',
'group': __("System configuration"), 'group': __("System configuration"),
'tasks': [ 'tasks': [
@ -292,7 +292,7 @@ class ClUpdateAction(Action):
(Get('cl_update_outdate_set') == 'on' or (Get('cl_update_outdate_set') == 'on' or
Get('cl_update_force_fix_set') == 'on')) Get('cl_update_force_fix_set') == 'on'))
}, },
{'name': 'dispatch_conf', {'name': 'dispatch_conf',
'message': __("Updating configuration files"), 'message': __("Updating configuration files"),
'method': 'Update.dispatchConf()', 'method': 'Update.dispatchConf()',
@ -300,12 +300,12 @@ class ClUpdateAction(Action):
Get('cl_update_pretend_set') == 'off' and Get('cl_update_pretend_set') == 'off' and
(Get('cl_update_outdate_set') == 'on' or (Get('cl_update_outdate_set') == 'on' or
Get('cl_update_force_fix_set') == 'on')) Get('cl_update_force_fix_set') == 'on'))
}, },
{'name': 'binhost_changed', {'name': 'binhost_changed',
'method': 'Update.message_binhost_changed()' 'method': 'Update.message_binhost_changed()'
}, },
] ]
} }
] + emerge_tasks + [ ] + emerge_tasks + [
{'name': 'failed', {'name': 'failed',
'error': __("Update failed"), 'error': __("Update failed"),

@ -25,7 +25,7 @@ from calculate.lib.datavars import (Variable, VariableError,
TableVariable, FieldValue, TableVariable, FieldValue,
HumanReadable, CriticalError, HumanReadable, CriticalError,
SimpleDataVars, DataVarsError) SimpleDataVars, DataVarsError)
from calculate.lib.utils.binhosts import Binhosts from calculate.lib.utils.binhosts import Binhosts, PackagesIndex, HOURS
from calculate.lib.utils.files import readFile, listDirectory, process, pathJoin from calculate.lib.utils.files import readFile, listDirectory, process, pathJoin
from calculate.lib.configparser import ConfigParser from calculate.lib.configparser import ConfigParser
@ -1706,9 +1706,22 @@ class VariableClUpdatePackageCache(ReadonlyVariable):
host, parsed_url.path.lstrip("/"), host, parsed_url.path.lstrip("/"),
"Packages") "Packages")
class VariableClUpdatePackageCacheSet(Variable): class VariableClUpdatePackageCacheSet(Variable):
""" """
Необходимость обновить Packages Необходимость обновить Packages
""" """
type = "bool" type = "bool"
value = "off"
def get(self):
packages_fn = self.Get('cl_update_package_cache')
if not path.exists(packages_fn):
return "on"
pi = PackagesIndex(readFile(packages_fn))
try:
ttl = int(pi.get("TTL", "0"))
if ttl > HOURS:
return "off"
except ValueError:
return "on"
return "on"

Loading…
Cancel
Save