Skip to content

Added autoclose functionality

Adds autoclose functionality, like !58 (closed) and !57 (closed), but this one works using the gate-auto-refresh hook, so no changes to snapd are required.

Currently, the snap-store snap runs permanently in the background to notify the user if there are new versions of both installed programs or firmware. If the user opens the store, the current process will show the window, no new process is launched. Also, when the user closes the window, it only hides it; the store will be kept running in the background. That means that whenever a new version of snap-store is available in the snap store, it can't be updated because the snap is running, and there is no direct way for the user to close it. The only way is for the user to open a terminal and manually kill the current snap-store process, which is cumbersome.

This MR uses the experimental gate-auto-refresh-hook to detect when there is a new version of the snap store, and kill the current snap store process if it's running, thus removing the need for the user to manually kill it.

The communication between the hook and the main program is done by writing a file called pending-refresh into the $SNAP_COMMON folder, where any snap-store instance can see it by using a GFileMonitor object. When this file appears there, the snap-store application knows that there is a pending update. If the main window is hidden, the snap-store process will close immediately, which will allow snapd to update it as expected.

But if the main window is visible, that means that the user is using the application, so it will just show a notification in the main window to inform the user that there is a pending update and that they must close the application to allow it to proceed (see the screen capture below). In that case, the application will exit only when the user closes the main window.

The pre-refresh and post-refresh hooks delete the "pending-refresh" file, because their execution means that the refresh is being done.

The "gate-auto-refresh" hook is still experimental, so it must be manually enabled with

sudo snap set system experimental.gate-auto-refresh-hook=true

The message showed is the same than in the other MRs:

image

This MR has been tested both with the current stable code (2.58.2), and also with the refresh-awareness patch in place and enabled. In both cases, when the application is running in the background and a new version is available, the current process is killed and refreshed automagically. But it also works fine with refresh-awareness code enabled: if the snap-store window is opened when the refresh is detected, when the user closes the window the snap is updated correctly.

Edited by Sergio Costas

Merge request reports