@@ -184,13 +184,23 @@ def update_with_lvgl(self, url):
184184if total_size :
185185self .progress_callback (bytes_written / total_size * 100 )
186186response .close ()
187- if bytes_written >= total_size and not simulate :# if the update was completely installed
188- next_partition .set_boot ()
189- import machine
190- machine .reset ()
191- # In case it didn't reset:
192- lv .async_call (lambda l :self .status_label .set_text ("Update finished! Please restart." ),None )
193- # self.install_button stays disabled to prevent the user from downloading an update twice
187+ try :
188+ if bytes_written >= total_size :
189+ if not simulate :# if the update was completely installed
190+ next_partition .set_boot ()
191+ import machine
192+ machine .reset ()
193+ # In case it didn't reset:
194+ lv .async_call (lambda l :self .status_label .set_text ("Update finished! Please restart." ),None )
195+ # self.install_button stays disabled to prevent the user from installing the same update twice
196+ else :
197+ print ("This is an OSUpdate simulation, not attempting to restart the device." )
198+ else :
199+ lv .async_call (lambda l :self .status_label .set_text (f"Wrote{ bytes_written } <{ total_size } so not enough!" ),None )
200+ self .install_button .remove_state (lv .STATE .DISABLED )# allow retry
201+ except Exception as e :
202+ lv .async_call (lambda l :self .status_label .set_text (f"Update error:{ e } " ),None )
203+ self .install_button .remove_state (lv .STATE .DISABLED )# allow retry
194204
195205# Non-class functions:
196206