Skip to content

Commit 6b55353

Browse files
committed
2.024 fix auto update error handler
1 parent f90558f commit 6b55353

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

xeHentai/updater/github.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@
77

88
from . import Updater, UpdateInfo
99

10+
class GithubUpdaterException(Exception):
11+
pass
12+
1013
class GithubUpdater(Updater):
1114
def __init__(self, session):
1215
self.session = session
1316

1417
def get_latest_release(self, dev=False):
1518
param = dev and "dev" or "master"
1619
r = self.session.get("https://api.github.com/repos/fffonion/xeHentai/commits?sha=%s" % param)
17-
commit = r.json()[0]
20+
commit = r.json()
21+
if r.status_code != 200 or not commit:
22+
raise GithubUpdaterException("Failed to get latest release info: %s" % r.text)
23+
commit = commit[0]
1824
sha = commit["sha"]
1925
url = "https://github.com/fffonion/xeHentai/archive/%s.zip" % sha
2026

xeHentai/updater/updater.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def check_update(l=None, config={}):
4040
with zipfile.ZipFile(StringIO(z)) as zf:
4141
make_src_update_file(zf, g.get_src_path_in_archive(info), info)
4242
l.info(i18n.UPDATE_COMPLETE)
43-
except MemoryError as ex:
43+
except Exception as ex:
4444
l.warn(i18n.UPDATE_FAILED % str(ex))
4545

4646

0 commit comments

Comments
 (0)