Make frozenage less reliant on changing _frozenlinks
The mtime of a file in OBS is the time this content was created for the first time. As such if the target project isn't moving for a week, staging select will keep asking you to freeze - even if you just froze. So instead of relying on OBS to tell the true mtime, set an attribute in the staging project and read from it. This also gives a way to check in the webui for the last freeze time Fixes #2462
This commit is contained in:
parent
003f010579
commit
66b778144f
5
dist/obs/OSRT:FreezeTime.xml
vendored
Normal file
5
dist/obs/OSRT:FreezeTime.xml
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
<definition name="FreezeTime" namespace="OSRT">
|
||||
<description>Date and time of the last call of freeze (updating _frozenlinks)</description>
|
||||
<count>1</count>
|
||||
<modifiable_by role="maintainer"/>
|
||||
</definition>
|
@ -1,7 +1,9 @@
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
from urllib.error import HTTPError
|
||||
from lxml import etree as ET
|
||||
import osc.core
|
||||
from osclib.core import attribute_value_save
|
||||
|
||||
MAX_FROZEN_AGE = 6.5
|
||||
|
||||
@ -197,6 +199,7 @@ class FreezeCommand(object):
|
||||
|
||||
url = self.api.makeurl(['source', self.prj, '_project', '_frozenlinks'], {'meta': '1'})
|
||||
self.api.retried_PUT(url, ET.tostring(flink))
|
||||
attribute_value_save(self.api.apiurl, self.prj, 'FreezeTime', datetime.now(timezone.utc).isoformat())
|
||||
|
||||
def receive_sources(self, prj, sources, flink):
|
||||
url = self.api.makeurl(['source', prj], {'view': 'info', 'nofilename': '1'})
|
||||
|
@ -879,6 +879,12 @@ class StagingAPI(object):
|
||||
:param project: project to check
|
||||
:return age in days(float) of the last update
|
||||
"""
|
||||
freezetime = attribute_value_load(self.apiurl, project, 'FreezeTime')
|
||||
if freezetime:
|
||||
freezetime = datetime.fromisoformat(freezetime)
|
||||
tz_info = freezetime.tzinfo
|
||||
return (datetime.now(tz_info) - freezetime).total_seconds() / 3600 / 24
|
||||
# fallback: old method
|
||||
root = ET.fromstring(self._fetch_project_meta(project))
|
||||
for entry in root.findall('entry'):
|
||||
if entry.get('name') == '_frozenlinks':
|
||||
|
Loading…
x
Reference in New Issue
Block a user