No need to write to shortcut file when no shortcut is removed

This commit is contained in:
Mathieu Comandon 2023-10-17 16:28:32 -07:00
parent 3a27de7a94
commit 5158fc37eb

View file

@ -108,6 +108,9 @@ def remove_shortcut(game):
with open(shortcut_path, "rb") as shortcut_file:
shortcuts = vdf.binary_loads(shortcut_file.read())['shortcuts'].values()
other_shortcuts = [s for s in shortcuts if not matches_id(s, game)]
# Quit early if no shortcut is removed
if len(shortcuts) == len(other_shortcuts):
return
updated_shortcuts = {
'shortcuts': {
str(index): elem for index, elem in enumerate(other_shortcuts)