mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 06:50:29 +03:00
[checkupdates] Simplify logic in check_http
This commit is contained in:
parent
8f836b3b01
commit
44a0e7e74f
1 changed files with 21 additions and 31 deletions
|
|
@ -45,9 +45,6 @@ from .exception import VCSException, NoSubmodulesException, FDroidException, Met
|
||||||
# required.
|
# required.
|
||||||
def check_http(app):
|
def check_http(app):
|
||||||
|
|
||||||
ignoreversions = app.UpdateCheckIgnore
|
|
||||||
ignoresearch = re.compile(ignoreversions).search if ignoreversions else None
|
|
||||||
|
|
||||||
if not app.UpdateCheckData:
|
if not app.UpdateCheckData:
|
||||||
raise FDroidException('Missing Update Check Data')
|
raise FDroidException('Missing Update Check Data')
|
||||||
|
|
||||||
|
|
@ -60,8 +57,6 @@ def check_http(app):
|
||||||
if not parsed.netloc or not parsed.scheme or parsed.scheme != 'https':
|
if not parsed.netloc or not parsed.scheme or parsed.scheme != 'https':
|
||||||
raise FDroidException(_('UpdateCheckData has invalid URL: {url}').format(url=urlcode))
|
raise FDroidException(_('UpdateCheckData has invalid URL: {url}').format(url=urlcode))
|
||||||
|
|
||||||
vercode = None
|
|
||||||
if urlcode:
|
|
||||||
logging.debug("...requesting {0}".format(urlcode))
|
logging.debug("...requesting {0}".format(urlcode))
|
||||||
req = urllib.request.Request(urlcode, None, headers=net.HEADERS)
|
req = urllib.request.Request(urlcode, None, headers=net.HEADERS)
|
||||||
resp = urllib.request.urlopen(req, None, 20) # nosec B310 scheme is filtered above
|
resp = urllib.request.urlopen(req, None, 20) # nosec B310 scheme is filtered above
|
||||||
|
|
@ -72,8 +67,6 @@ def check_http(app):
|
||||||
raise FDroidException("No RE match for version code")
|
raise FDroidException("No RE match for version code")
|
||||||
vercode = m.group(1).strip()
|
vercode = m.group(1).strip()
|
||||||
|
|
||||||
version = "??"
|
|
||||||
if urlver:
|
|
||||||
if urlver != '.':
|
if urlver != '.':
|
||||||
logging.debug("...requesting {0}".format(urlver))
|
logging.debug("...requesting {0}".format(urlver))
|
||||||
req = urllib.request.Request(urlver, None)
|
req = urllib.request.Request(urlver, None)
|
||||||
|
|
@ -85,13 +78,10 @@ def check_http(app):
|
||||||
raise FDroidException("No RE match for version")
|
raise FDroidException("No RE match for version")
|
||||||
version = m.group(1)
|
version = m.group(1)
|
||||||
|
|
||||||
if ignoresearch and version:
|
if app.UpdateCheckIgnore and re.search(app.UpdateCheckIgnore, version):
|
||||||
if not ignoresearch(version):
|
|
||||||
return (version, vercode)
|
|
||||||
else:
|
|
||||||
logging.info("Version {version} for {appid} is ignored".format(version=version, appid=app.id))
|
logging.info("Version {version} for {appid} is ignored".format(version=version, appid=app.id))
|
||||||
return (None, None)
|
return (None, None)
|
||||||
else:
|
|
||||||
return (version, vercode)
|
return (version, vercode)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue