[GTKUI] [Win32] Fix 'access is denied' with magnet association

* Issue occurs with user without administrator privileges
 * See github pull request #19 for details
This commit is contained in:
doadin 2014-11-06 01:48:30 -05:00 committed by Calum Lind
parent aede6f9ce5
commit dd8d2c8557
1 changed files with 6 additions and 1 deletions

View File

@ -172,7 +172,12 @@ def associate_magnet_links(overwrite=False):
if overwrite:
deluge_exe = os.path.join(os.path.dirname(sys.executable), "deluge.exe")
magnet_key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "Magnet")
try:
magnet_key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "Magnet")
except WindowsError:
# Could not create for all users, falling back to current user
magnet_key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, "Software\\Classes\\Magnet")
_winreg.SetValue(magnet_key, "", _winreg.REG_SZ, "URL:Magnet Protocol")
_winreg.SetValueEx(magnet_key, "URL Protocol", 0, _winreg.REG_SZ, "")
_winreg.SetValueEx(magnet_key, "BrowserFlags", 0, _winreg.REG_DWORD, 0x8)