1
0

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'
```
This commit is contained in:
f321x
2025-08-04 09:50:15 +02:00
parent 8e5f29e890
commit 050b5b8076

View File

@@ -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):