mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-19 21:30:10 +01:00
[checkupdates] Simplify logic in check_http
This commit is contained in:
parent
8f836b3b01
commit
44a0e7e74f
@ -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,39 +57,32 @@ 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
|
logging.debug("...requesting {0}".format(urlcode))
|
||||||
if urlcode:
|
req = urllib.request.Request(urlcode, None, headers=net.HEADERS)
|
||||||
logging.debug("...requesting {0}".format(urlcode))
|
resp = urllib.request.urlopen(req, None, 20) # nosec B310 scheme is filtered above
|
||||||
req = urllib.request.Request(urlcode, None, headers=net.HEADERS)
|
page = resp.read().decode('utf-8')
|
||||||
|
|
||||||
|
m = re.search(codeex, page)
|
||||||
|
if not m:
|
||||||
|
raise FDroidException("No RE match for version code")
|
||||||
|
vercode = m.group(1).strip()
|
||||||
|
|
||||||
|
if urlver != '.':
|
||||||
|
logging.debug("...requesting {0}".format(urlver))
|
||||||
|
req = urllib.request.Request(urlver, None)
|
||||||
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
|
||||||
page = resp.read().decode('utf-8')
|
page = resp.read().decode('utf-8')
|
||||||
|
|
||||||
m = re.search(codeex, page)
|
m = re.search(verex, page)
|
||||||
if not m:
|
if not m:
|
||||||
raise FDroidException("No RE match for version code")
|
raise FDroidException("No RE match for version")
|
||||||
vercode = m.group(1).strip()
|
version = m.group(1)
|
||||||
|
|
||||||
version = "??"
|
if app.UpdateCheckIgnore and re.search(app.UpdateCheckIgnore, version):
|
||||||
if urlver:
|
logging.info("Version {version} for {appid} is ignored".format(version=version, appid=app.id))
|
||||||
if urlver != '.':
|
return (None, None)
|
||||||
logging.debug("...requesting {0}".format(urlver))
|
|
||||||
req = urllib.request.Request(urlver, None)
|
|
||||||
resp = urllib.request.urlopen(req, None, 20) # nosec B310 scheme is filtered above
|
|
||||||
page = resp.read().decode('utf-8')
|
|
||||||
|
|
||||||
m = re.search(verex, page)
|
return (version, vercode)
|
||||||
if not m:
|
|
||||||
raise FDroidException("No RE match for version")
|
|
||||||
version = m.group(1)
|
|
||||||
|
|
||||||
if ignoresearch and version:
|
|
||||||
if not ignoresearch(version):
|
|
||||||
return (version, vercode)
|
|
||||||
else:
|
|
||||||
logging.info("Version {version} for {appid} is ignored".format(version=version, appid=app.id))
|
|
||||||
return (None, None)
|
|
||||||
else:
|
|
||||||
return (version, vercode)
|
|
||||||
|
|
||||||
|
|
||||||
def check_tags(app, pattern):
|
def check_tags(app, pattern):
|
||||||
|
Loading…
Reference in New Issue
Block a user