Skip to content

Commit

Permalink
error handling for vdf
Browse files Browse the repository at this point in the history
  • Loading branch information
moraroy authored Jun 19, 2024
1 parent 4f77e05 commit cc2b405
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions NSLGameScanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,15 @@ def get_unsigned_shortcut_id(signed_shortcut_id):
shortcuts = {'shortcuts': {}}
except Exception as e:
print(f"Error reading shortcuts file: {e}")
# If an error occurs when reading the file, create a new file with an empty "shortcuts" section
with open(shortcuts_file, 'wb') as file:
vdf.binary_dumps({'shortcuts': {}}, file)
print("Please check the file and try again.")
return

# Check data integrity before writing to file
if shortcuts and isinstance(shortcuts, dict) and 'shortcuts' in shortcuts:
with open(shortcuts_file, 'wb') as file:
vdf.binary_dumps(shortcuts, file)
else:
print("The data to be written to the shortcuts file is not valid.")


# Open the config.vdf file
Expand Down

0 comments on commit cc2b405

Please sign in to comment.