Clean up dashboard ping result post-rename/delete (#4170)

This commit is contained in:
Paulus Schoutsen 2023-01-15 19:31:03 -05:00 committed by GitHub
parent a9b7d98194
commit 27185265f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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