mirror of
https://github.com/yuukiwww/taiko-web.git
synced 2024-10-22 17:05:49 +02:00
Admin: Fix hashing if songs baseurl is not absolute
This commit is contained in:
parent
54a98b77d9
commit
8d8a4577d2
6
app.py
6
app.py
@ -52,10 +52,16 @@ def generate_hash(id, form):
|
|||||||
urls.append('%s%s/%s.osu' % (config.SONGS_BASEURL, id, diff))
|
urls.append('%s%s/%s.osu' % (config.SONGS_BASEURL, id, diff))
|
||||||
|
|
||||||
for url in urls:
|
for url in urls:
|
||||||
|
if url.startswith("http://") or url.startswith("https://"):
|
||||||
resp = requests.get(url)
|
resp = requests.get(url)
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
raise HashException('Invalid response from %s (status code %s)' % (resp.url, resp.status_code))
|
raise HashException('Invalid response from %s (status code %s)' % (resp.url, resp.status_code))
|
||||||
md5.update(resp.content)
|
md5.update(resp.content)
|
||||||
|
else:
|
||||||
|
if url.startswith("/"):
|
||||||
|
url = url[1:]
|
||||||
|
with open(os.path.join("public", url), "rb") as file:
|
||||||
|
md5.update(file.read())
|
||||||
|
|
||||||
return base64.b64encode(md5.digest())[:-2].decode('utf-8')
|
return base64.b64encode(md5.digest())[:-2].decode('utf-8')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user