remove last-screen file before restarting or exiting

unless we are restarting because of a snap refresh.

ths lead to all kinds of confusion after e.g. a ui crash after a snap refresh
This commit is contained in:
Michael Hudson-Doyle 2020-03-16 16:37:16 +13:00
parent 499cd78c1e
commit 94611c58e2
3 changed files with 9 additions and 3 deletions

View File

@ -92,7 +92,7 @@ class RefreshController(SubiquityController):
if change['status'] == 'Done':
# Clearly if we got here we didn't get restarted by
# snapd/systemctl (dry-run mode or logged in via SSH)
self.app.restart()
self.app.restart(remove_last_screen=False)
if change['status'] not in ['Do', 'Doing']:
raise Exception("update failed")
await asyncio.sleep(0.1)

View File

@ -131,7 +131,9 @@ class Subiquity(Application):
else:
super().exit()
def restart(self):
def restart(self, remove_last_screen=True):
if remove_last_screen:
self._remove_last_screen()
self.urwid_loop.screen.stop()
cmdline = ['snap', 'run', 'subiquity']
if self.opts.dry_run:
@ -168,6 +170,7 @@ class Subiquity(Application):
report = self.make_apport_report(
ErrorReportKind.UI, "Installer UI", interrupt=False, wait=True)
print("report saved to {}".format(report.path))
self._remove_last_screen()
raise
def report_start_event(self, name, description, level="INFO"):

View File

@ -485,10 +485,13 @@ class Application:
# EventLoop -------------------------------------------------------------------
def exit(self):
def _remove_last_screen(self):
state_path = os.path.join(self.state_dir, 'last-screen')
if os.path.exists(state_path):
os.unlink(state_path)
def exit(self):
self._remove_last_screen()
self.aio_loop.stop()
def run_scripts(self, scripts):