TG-80 TG-50

cl-update: Fix: current binhost now drops after "-m auto"
cl-update: Feature: "--one-depth" now have bool3 type
master 3.7.2.62
root 1 year ago
parent ee6aa3c018
commit 017fc09c31

@ -59,7 +59,8 @@ def get_synchronization_tasks(object_name):
'method': Object('check_current_binhost(update.cl_update_binhost)'),
'condition': lambda GetBool, Get: (
not GetBool('update.cl_update_binhost_recheck_set') and
not (Get('update.cl_update_binhost_choice') and Get('update.cl_update_binhost_choice') != 'auto') and
not Get('update.cl_update_binhost_choice') and
Get('update.cl_update_binhost_choice') != 'auto' and
Get('update.cl_update_sync_rep') and
Get('update.cl_update_binhost') and
Get('update.cl_update_use_migration_host') == 'off')

@ -18,6 +18,7 @@ import os
import sys
import re
from os import path
import datetime
from calculate.lib.cl_template import SystemIni
from calculate.lib.cl_log import log
from calculate.lib.datavars import (Variable, VariableError,
@ -1811,8 +1812,10 @@ class VariableClUpdateOnedepthSet(Variable):
"""
Удлять лишние файлы из репозиториев (например созданные пользователем)
"""
type = "bool"
value = "off"
type = "bool3"
value = 'auto'
max_interval = 'cl_update_onedepth_interval'
check_after = 'cl_update_onedepth_interval'
opt = ["--one-depth", "-1"]
@ -1820,6 +1823,43 @@ class VariableClUpdateOnedepthSet(Variable):
self.label = _("Clear the history of repositories")
self.help = _("clear the history of repositories")
def get_oldest_history(self, rep):
try:
with open(f'{rep}/.git/logs/HEAD') as inf:
oldest_timestamp = int(inf.readline().split()[4])
date = datetime.datetime.fromtimestamp(oldest_timestamp)
return datetime.datetime.now() - date
except OSError:
return 0
def set(self, value):
try:
if value == 'auto' or value is None:
rep_path = self.Get('cl_update_rep_path')
for rep in rep_path:
if self.get_oldest_history(rep).days > int(self.Get(self.max_interval)):
self.value = 'on'
return 'on'
self.value = 'off'
return 'off'
except:
return 'off'
self.value = value
return self.value
def get(self):
if self.value == 'auto' or self.value is None:
return self.set(self.value)
return self.value
class VariableClUpdateOnedepthInterval(Variable):
default_value = 0
def get(self):
if not self.value:
return self.default_value
return self.value
class VariableClUpdateEixRepositories(ReadonlyVariable):
"""

Loading…
Cancel
Save