Senth / minecraft-mod-manager

Install and update mods from CurseForge and Modrinth through a CLI
MIT License
75 stars 7 forks source link

sqlite3.IntegrityError: UNIQUE constraint failed: mod.id #186

Open theofficialgman opened 2 years ago

theofficialgman commented 2 years ago

Describe the bug

installed a modpack and attempted to run the mmm updater (just for testing, I know this in general is a bad idea). it made it through about 25 mods or so and then threw this error.

citresewn
    πŸ” Searching for mod
Traceback (most recent call last):
  File "/home/garrett/.local/bin/minecraft-mod-manager", line 8, in <module>
    sys.exit(main())
  File "/home/garrett/.local/lib/python3.8/site-packages/minecraft_mod_manager/__main__.py", line 38, in main
    update.execute(config.arg_mods)
  File "/home/garrett/.local/lib/python3.8/site-packages/minecraft_mod_manager/app/update/update.py", line 31, in execute
    self.find_download_and_install(mods_to_update)
  File "/home/garrett/.local/lib/python3.8/site-packages/minecraft_mod_manager/app/download/download.py", line 35, in find_download_and_install
    mod.sites = self._finder.find_mod(mod)
  File "/home/garrett/.local/lib/python3.8/site-packages/minecraft_mod_manager/gateways/api/mod_finder.py", line 82, in find_mod
    infos = api.search_mod(split_word)
  File "/home/garrett/.local/lib/python3.8/site-packages/minecraft_mod_manager/gateways/api/modrinth_api.py", line 53, in search_mod
    mods = self._search_mod(search)
  File "/home/garrett/.local/lib/python3.8/site-packages/minecraft_mod_manager/gateways/api/modrinth_api.py", line 73, in _search_mod
    for mod_info in json["hits"]:
KeyError: 'hits'
Traceback (most recent call last):
  File "/home/garrett/.local/lib/python3.8/site-packages/minecraft_mod_manager/gateways/sqlite.py", line 202, in insert_mod
    self._cursor.execute(
sqlite3.IntegrityError: UNIQUE constraint failed: mod.id

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/garrett/.local/bin/minecraft-mod-manager", line 8, in <module>
    sys.exit(main())
  File "/home/garrett/.local/lib/python3.8/site-packages/minecraft_mod_manager/__main__.py", line 33, in main
    repo = RepoImpl(jar_parser, sqlite, http)
  File "/home/garrett/.local/lib/python3.8/site-packages/minecraft_mod_manager/adapters/repo_impl.py", line 27, in __init__
    self.mods = self.db.sync_with_dir(jar_parser.mods)
  File "/home/garrett/.local/lib/python3.8/site-packages/minecraft_mod_manager/gateways/sqlite.py", line 136, in sync_with_dir
    self.insert_mod(mod)
  File "/home/garrett/.local/lib/python3.8/site-packages/minecraft_mod_manager/gateways/sqlite.py", line 213, in insert_mod
    raise ModAlreadyExists(mod)
minecraft_mod_manager.core.errors.mod_already_exists.ModAlreadyExists: Mod cloth-config already found in the the db.

Steps to reproduce

Steps to reproduce the behavior:

  1. installed Fabulously Optimized 3.8.1 using multimc new modrinth modpack installer
  2. ran mcman update

Expected Behavior

expected mods to update without error (or be skipped if not found)

Info

cobalt2727 commented 2 years ago

Receiving the same error, I installed Fabulously Optimized a very long time ago, and added and removed a few mods to better match my needs. What with GDLauncher's CF integration being broken by Overwolf, I tried using this in my mod folder to update and got the following: cobalt@cobalt-inspiron:~/.config/gdlauncher_next/instances/Fabulously Optimized/mods$ minecraft-mod-manager -v 1.18.2 --beta --alpha --mod-loader fabric --verbose update

Found fabric mod: entity_texture_features-2.6.0 (Entity Texture Features) [fabric]
Found fabric mod: cloth-api-3.2.64 (Cloth API) [fabric]
Found fabric mod: lithium-0.7.10 (Lithium) [fabric]
Found fabric mod: sodium-0.4.1+build.15 (Sodium) [fabric]
Found fabric mod: smoothboot-1.18.2-1.7.0 (Smooth Boot) [fabric]
Found fabric mod: animatica-0.4+1.18 (Animatica) [fabric]
Found fabric mod: nofade-1.18-2.0.1 (No Fade) [fabric]
Found fabric mod: enhancedblockentities-0.6+1.18.2 (Enhanced Block Entities) [fabric]
Found fabric mod: fabrishot-${version} (Fabrishot) [fabric]
Found fabric mod: capes-1.3.1+1.18.2 (Capes) [fabric]
Found fabric mod: chat-control-1.1 (Chat Control) [fabric]
Found fabric mod: no-telemetry-1.3.0 (No Telemetry) [fabric]
Found fabric mod: antighost-1.18.2-fabric0.47.10-1.1.4 (AntiGhost) [fabric]
Found fabric mod: modmenu-3.2.1 (Mod Menu) [fabric]
Found fabric mod: puzzle-1.2.1 (Puzzle) [fabric]
Found fabric mod: fabric-0.51.1+1.18.2 (Fabric API) [fabric]
Found fabric mod: indium-1.0.3+mc1.18.2 (Indium) [fabric]
Found fabric mod: fallingleaves-1.11.1+1.18.2 (Falling Leaves) [fabric]
Found fabric mod: lambdynlights-2.1.0+1.17 (LambDynamicLights) [fabric]
Found fabric mod: completeconfig-1.4.1 (CompleteConfig) [fabric]
Found fabric mod: xaeroworldmap-1.20.6 (Xaero's World Map) [fabric]
Found fabric mod: farsight-1.18-1.9 (Farsight Mod) [fabric]
Found fabric mod: yosbr-0.1.1 (YOSBR) [fabric]
Found fabric mod: dynamicfps-2.1.0 (Dynamic FPS) [fabric]
Found fabric mod: morechathistory-1.1.0 (MoreChatHistory) [fabric]
Found fabric mod: slight-gui-modifications-2.1.0 ('Slight' GUI Modifications) [fabric]
Found fabric mod: starlight-1.0.2+fabric.89b8d9f (Starlight) [fabric]
Found fabric mod: lazydfu-0.1.2 (LazyDFU) [fabric]
Found fabric mod: bettermounthud-1.1.4 (Better Mount HUD) [fabric]
Found fabric mod: languagereload-1.2.1 (Language Reload) [fabric]
Found fabric mod: tooltipfix-1.0.4-1.18 (ToolTip Fix) [fabric]
Found fabric mod: dcch-1.0 (DCCH) [fabric]
Found fabric mod: debugify-1.10.0 (Debugify) [fabric]
Found fabric mod: xaerominimap-22.6.0 (Xaero's Minimap) [fabric]
Found fabric mod: ferritecore-4.2.1 (FerriteCore) [fabric]
Found fabric mod: itemmodelfix-1.0.3+1.18 (Item Model Fix) [fabric]
Found fabric mod: borderlessmining-1.1.2+1.18.2 (Borderless Mining) [fabric]
Found fabric mod: okzoomer-5.0.0-beta.6+1.18.2 (Ok Zoomer) [fabric]
Found fabric mod: advancementinfo-1.18.2-fabric0.47.10-1.3.1 (AdvancementInfo) [fabric]
Found fabric mod: cloth-config-6.2.57 (Cloth Config v6) [fabric]
Found fabric mod: colormatic-3.1.1+mc.1.18.2 (Colormatic) [fabric]
Found fabric mod: fabric-language-kotlin-1.7.4+kotlin.1.6.21 (Fabric Language Kotlin) [fabric]
Found fabric mod: midnightlib-0.4.0 (MidnightLib) [fabric]
Found fabric mod: iris-1.2.4-build.38 (Iris) [fabric]
Found fabric mod: continuity-1.1.0+1.18.2 (Continuity) [fabric]
Found fabric mod: notenoughcrashes-4.1.6+1.18.2 (Not Enough Crashes) [fabric]
Found fabric mod: cullleaves-2.3.2 (Cull Leaves) [fabric]
Found fabric mod: lambdabettergrass-1.2.3+1.18 (LambdaBetterGrass) [fabric]
Found fabric mod: fabric-0.53.4+1.18.2 (Fabric API) [fabric]
Found fabric mod: architectury-4.3.53 (Architectury) [fabric]
Found fabric mod: citresewn-1.0.1+1.18.2 (CIT Resewn) [fabric]
Found fabric mod: entityculling-1.5.1 (EntityCulling-Fabric) [fabric]
Found fabric mod: cem-0.7.1 (Custom Entity Models) [fabric]
Traceback (most recent call last):
  File "/home/cobalt/.local/lib/python3.10/site-packages/minecraft_mod_manager/gateways/sqlite.py", line 202, in insert_mod
    self._cursor.execute(
sqlite3.IntegrityError: UNIQUE constraint failed: mod.id

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cobalt/.local/bin/minecraft-mod-manager", line 8, in <module>
    sys.exit(main())
  File "/home/cobalt/.local/lib/python3.10/site-packages/minecraft_mod_manager/__main__.py", line 33, in main
    repo = RepoImpl(jar_parser, sqlite, http)
  File "/home/cobalt/.local/lib/python3.10/site-packages/minecraft_mod_manager/adapters/repo_impl.py", line 27, in __init__
    self.mods = self.db.sync_with_dir(jar_parser.mods)
  File "/home/cobalt/.local/lib/python3.10/site-packages/minecraft_mod_manager/gateways/sqlite.py", line 136, in sync_with_dir
    self.insert_mod(mod)
  File "/home/cobalt/.local/lib/python3.10/site-packages/minecraft_mod_manager/gateways/sqlite.py", line 213, in insert_mod
    raise ModAlreadyExists(mod)
minecraft_mod_manager.core.errors.mod_already_exists.ModAlreadyExists: Mod fabric already found in the the db.

OS: Pop!_OS 22.04 Python version: 3.10.4 minecraft-mod-manager --version: 1.3.0

cobalt2727 commented 2 years ago

Tried removing .minecraft-mod-manager.db, same issue happened.

theofficialgman commented 2 years ago

I don't think your error is the same cobalt. regardless I still get my issue randomly.

the only solution is to delete the .minecraft-mod-manager.db and try again at which point it may randomly work after trying multiple times

Senth commented 2 years ago

Thanks for reporting, both of you πŸ™‚

I also think the issues might be different.

The first one might be because it has trouble finding the correct mod. I'll have to look into this a bit more.

The second issue for @cobalt2727 is probably either that fabric-api has two files in the folder or that some other mod also specified its id as fabric. This issue is then related to #59. That this should be handled a bit better if there are multiple mods with the same id.

I'm thinking that the second solution will be solved in v1.4 as I'm planning to migrate the SQLite DB into a JSON format so that it's a lot more user-friendly for those that want to configure mods manually.