From 050b5b80760ce0d8012c9e6268bd6d6aa6e5d9f6 Mon Sep 17 00:00:00 2001 From: f321x Date: Mon, 4 Aug 2025 09:50:15 +0200 Subject: [PATCH] qt: handle shutil.copyfail exc in add_plugin_dialog Handles exceptions thrown by `shutil.copyfile()` in the `add_plugin_dialog`. In issue #10101 an user tried to access an onedrive vault directory which made shutil fail to copy the file with: ``` OSError: [Errno 22] Invalid argument: 'odopen://unlockvault/?accounttype=personal' ``` --- electrum/gui/qt/plugins_dialog.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/electrum/gui/qt/plugins_dialog.py b/electrum/gui/qt/plugins_dialog.py index 2c1171fcd..239c5e94b 100644 --- a/electrum/gui/qt/plugins_dialog.py +++ b/electrum/gui/qt/plugins_dialog.py @@ -281,7 +281,15 @@ class PluginsDialog(WindowModalDialog, MessageBoxMixin): if os.path.exists(path): self.show_warning(_('Plugin already installed.')) return - shutil.copyfile(filename, path) + try: + shutil.copyfile(filename, path) + except OSError as e: + self.show_error(_("Could not copy plugin file {} into directory {}:\n\n{}").format( + filename, + path, + str(e) + )) + return self._try_add_external_plugin_from_path(path) def _try_add_external_plugin_from_path(self, path: str):