From 27185265f6f350decd7842e238f8d8ba4ad57093 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 15 Jan 2023 19:31:03 -0500 Subject: [PATCH] Clean up dashboard ping result post-rename/delete (#4170) --- esphome/dashboard/dashboard.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/esphome/dashboard/dashboard.py b/esphome/dashboard/dashboard.py index c224990319..d995614c2a 100644 --- a/esphome/dashboard/dashboard.py +++ b/esphome/dashboard/dashboard.py @@ -281,8 +281,11 @@ class EsphomeLogsHandler(EsphomeCommandWebSocket): class EsphomeRenameHandler(EsphomeCommandWebSocket): + old_name: str + def build_command(self, json_message): config_file = settings.rel_path(json_message["configuration"]) + self.old_name = json_message["configuration"] return [ "esphome", "--dashboard", @@ -291,6 +294,15 @@ class EsphomeRenameHandler(EsphomeCommandWebSocket): json_message["newName"], ] + def _proc_on_exit(self, returncode): + super()._proc_on_exit(returncode) + + if returncode != 0: + return + + # Remove the old ping result from the cache + PING_RESULT.pop(self.old_name, None) + class EsphomeUploadHandler(EsphomeCommandWebSocket): def build_command(self, json_message): @@ -859,6 +871,9 @@ class DeleteRequestHandler(BaseHandler): if build_folder is not None: shutil.rmtree(build_folder, os.path.join(trash_path, name)) + # Remove the old ping result from the cache + PING_RESULT.pop(configuration, None) + class UndoDeleteRequestHandler(BaseHandler): @authenticated