minecraft-mod-manager icon indicating copy to clipboard operation
minecraft-mod-manager copied to clipboard

Handle multiple mod versions (don't crash)

Open Senth opened this issue 4 years ago • 0 comments

Problem

Currently if there are two or more mods with the same id the application will crash. The application can't add multiple mods with the same id to the database

Copied from #54

Traceback (most recent call last):
  File "c:\python39\lib\site-packages\minecraft_mod_manager\gateways\sqlite.py", line 138, in insert_mod
    self._connection.execute(
sqlite3.IntegrityError: UNIQUE constraint failed: mod.id

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python39\Scripts\minecraft-mod-manager.exe\__main__.py", line 7, in <module>
  File "c:\python39\lib\site-packages\minecraft_mod_manager\__main__.py", line 21, in main
    repo = RepoImpl(jar_parser, sqlite, downloader)
  File "c:\python39\lib\site-packages\minecraft_mod_manager\adapters\repo_impl.py", line 26, in __init__
    self.mods = self.db.sync_with_dir(jar_parser.mods)
  File "c:\python39\lib\site-packages\minecraft_mod_manager\gateways\sqlite.py", line 65, in sync_with_dir
    self.insert_mod(mod)
  File "c:\python39\lib\site-packages\minecraft_mod_manager\gateways\sqlite.py", line 151, in insert_mod
    raise ModAlreadyExists(mod)
minecraft_mod_manager.core.errors.mod_already_exists.ModAlreadyExists: Mod architectury already found in the the db.

Possible solutions

  • Only load the latest version
  • Ask the user which version to keep (and ask if the other ones should be deleted)

Senth avatar Jun 03 '21 19:06 Senth