Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions xeH.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def load_update():
with zipfile.ZipFile(SRC_UPDATE_FILE, 'r') as z:
try:
r = json.loads(z.read("info.json"))
except:
except Exception:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While replacing the bare except is a good practice, the logic in the following else block (line 25) contains two significant issues that will cause the update process to fail:

  1. NameError: SRC_UPDATE_VERSION is used but not defined in this scope. It should be const.SRC_UPDATE_VERSION.
  2. Logic Error: The condition if 'v' not in r and r['v'] != SRC_UPDATE_VERSION: is incorrect. If 'v' is missing, it will raise a KeyError when attempting to access r['v']. If 'v' is present, the and will short-circuit and never check the version value. It should likely use or instead of and.

Since these issues lead to an exception that triggers the outer handler and deletes the update file, they should be addressed to make the update mechanism functional.

need_remove = True
else:
if 'v' not in r and r['v'] != SRC_UPDATE_VERSION:
Expand All @@ -36,7 +36,7 @@ def load_update():
reload(xeHentai)
xeHentai.const.VERSION_UPDATE = update_id
xeHentai.const.VERSION_UPDATE_LOADER = v
except:
except Exception:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Swallowing all exceptions silently here makes it difficult to debug issues with the update process, such as syntax errors in the downloaded code or a corrupted zip file. Consider logging the error or printing it to sys.stderr before proceeding with the cleanup.

        except Exception as e:
            sys.stderr.write("Failed to load update: %s\n" % e)

if sys.path[0] == SRC_UPDATE_FILE:
sys.path.pop(0)
os.remove(SRC_UPDATE_FILE)
Expand Down
Loading