Made it far less likely for the UI to lock up

This commit is contained in:
David Carley
2021-03-23 21:19:45 -07:00
parent 47cec0dae3
commit a46230656e
13 changed files with 62 additions and 46 deletions

View File

@@ -79,7 +79,11 @@ class FileHandler(bbctrl.APIHandler):
if not filename: raise HTTPError(400, 'Missing filename')
filename = os.path.basename(filename)
with open(self.get_upload(filename).encode('utf8'), 'r') as f:
self.write(f.read())
try:
with open(self.get_upload(filename).encode('utf8'), 'r') as f:
self.write(f.read())
except Exception:
self.get_ctrl().state.select_file('')
raise HTTPError(400, "Unable to read file - doesn't appear to be GCode.")
self.get_ctrl().state.select_file(filename)