From dd8d2c85576a66dc4587b348d6b2222b4b490a90 Mon Sep 17 00:00:00 2001 From: doadin Date: Thu, 6 Nov 2014 01:48:30 -0500 Subject: [PATCH] [GTKUI] [Win32] Fix 'access is denied' with magnet association * Issue occurs with user without administrator privileges * See github pull request #19 for details --- deluge/ui/gtkui/common.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/deluge/ui/gtkui/common.py b/deluge/ui/gtkui/common.py index 960a862af..ddaad1749 100644 --- a/deluge/ui/gtkui/common.py +++ b/deluge/ui/gtkui/common.py @@ -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)