affederaffe / BeatSaberModManager

Yet another mod installer for Beat Saber, heavily inspired by ModAssistant.
MIT License
111 stars 5 forks source link

Nukes all of my default programs when run #2

Closed ChrisJAllan closed 2 years ago

ChrisJAllan commented 2 years ago

Running Arch Linux.

Log:

mv: cannot stat '/home/chris/.config/mimeapps.list.new': No such file or directory
-n,-f,--relativeToPwd,Beat Saber.exe
Restoring old version... 
Copying /media/SSD/Games/Steam/steamapps/common/Beat Saber/winhttp.dll                                                                                                                                                                                                           
Creating plugins folder... 
affederaffe commented 2 years ago

Hi, first of all I'm sorry it took so long to answer.

I'm also running Arch and sadly cannot reproduce the issue. Does this happen at startup or when checking the checkboxes for OneClick support?

affederaffe commented 2 years ago

Closing due to inactivty.

ChrisJAllan commented 2 years ago

It happens sometimes™ on startup.

After much testing, it turns out xdg-mime isn't perfectly thread-safe, and can wipe the mimeapps.list file if it's called in parallel. Easy way to show this:

parallel xdg-mime default BeatSaberModManager-url-beatsaver.desktop  ::: x-scheme-handler/beatsaver{,,,,,}

though it might still need to be run multiple times, race conditions are annoying like that.

Edit: This has been reported upstream a while ago: https://gitlab.freedesktop.org/xdg/xdg-utils/-/issues/171

I have now worked around this by injecting locking into xdg-mime:

#!/bin/bash

flock /tmp/xdg-mime.lock /usr/bin/xdg-mime "$@"
affederaffe commented 2 years ago

I introduced a lock which should prevent calling xdg-mime in parallel. I've tested this by registering and unregistering a protocol handler in a loop and couldn't detect any faulty behaviour, though do you mind testing it yourself? A build can be found at https://github.com/affederaffe/BeatSaberModManager/actions/runs/2436708259.

ChrisJAllan commented 2 years ago

Seems fixed, hasn't happened again with the test version (without my other lock, though I think I will leave that on for now, this should really be fixed upstream)