From f6baf36fabf645d29c9e0e5aae57199a259c8c57 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 7 Jan 2024 13:42:59 +1100 Subject: [PATCH] Check file exists before attempting flash (#435) --- macos/QMK Toolbox/MainViewController.swift | 5 +++++ windows/QMK Toolbox/MainWindow.cs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/macos/QMK Toolbox/MainViewController.swift b/macos/QMK Toolbox/MainViewController.swift index 08d0f3a7b5..cdf5e98c94 100644 --- a/macos/QMK Toolbox/MainViewController.swift +++ b/macos/QMK Toolbox/MainViewController.swift @@ -120,6 +120,11 @@ class MainViewController: NSViewController, USBListenerDelegate { return } + guard FileManager.default.fileExists(atPath: file) else { + logTextView.logError("File does not exist") + return + } + guard mcuBox.indexOfSelectedItem > 0 else { logTextView.logError("Please select a microcontroller") return diff --git a/windows/QMK Toolbox/MainWindow.cs b/windows/QMK Toolbox/MainWindow.cs index 482c99f795..ecbd13004f 100644 --- a/windows/QMK Toolbox/MainWindow.cs +++ b/windows/QMK Toolbox/MainWindow.cs @@ -271,6 +271,12 @@ private async void FlashAllAsync() return; } + if (!File.Exists(filePath)) + { + logTextBox.LogError("File does not exist!"); + return; + } + if (!windowState.AutoFlashEnabled) { Invoke(new Action(DisableUI));