fix(linux): check for existing file before trying to install

Under some circumstances it's possible that the user manages to select
a directory instead of a kmp file, or manually enters a non-existing file.
Is used to throw an error that we caught on Sentry; the user was able to
continue to use the app. This change now checks for a valid file before
trying to install the kmp file.

Fixes: #15572
Fixes: KEYMAN-LINUX-99
This commit is contained in:
Eberhard Beilharz 2026-02-09 15:51:03 +01:00
parent 96bae4296f
commit 7941b3d4a1
No known key found for this signature in database
GPG key ID: E9140597606020D3

View file

@ -74,14 +74,18 @@ class ViewInstalledWindowBase(Gtk.Window):
filter_text.set_name(_("KMP files"))
filter_text.add_pattern("*.kmp")
dlg.add_filter(filter_text)
response = dlg.run()
if response != Gtk.ResponseType.OK:
dlg.destroy()
return
while True:
response = dlg.run()
if response != Gtk.ResponseType.OK:
dlg.destroy()
return
file = dlg.get_filename()
dlg.destroy()
self.restart(self.install_file(file))
file = dlg.get_filename()
if file and os.path.isfile(file) and os.path.splitext(file)[1] == '.kmp':
dlg.destroy()
self.restart(self.install_file(file))
return
# Loop until we have a valid file or the user cancels the dialog
def install_file(self, kmpfile, language=None):
installDlg = InstallKmpWindow(kmpfile, viewkmp=self, language=language)