Skip to content

Commit

Permalink
sideload-repos-systemd: Don't launch service in a tight loop
Browse files Browse the repository at this point in the history
man systemd.path has the following to say:

> When a service unit triggered by a path unit terminates (regardless
> whether it exited successfully or failed), monitored paths are checked
> immediately again, and the service accordingly restarted instantly.

On my system, I observe that once /run/media/wjt is created,
flatpak-sideload-usb-repo.service is invoked in a tight loop. I think
what's happening is that PathExists=/run/media/wjt continues to be true,
so the service keeps getting restarted.

What we instead want is to activate the .service:

- On login
- When the media directory *changes* (because mount points beneath it
  appear or disappear)

Remove PathExists from the .path, and instead mark the .service as
WantedBy default.target so it is launched on login.
  • Loading branch information
wjt committed Sep 18, 2020
1 parent 8c61324 commit c43e8e1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 0 additions & 1 deletion sideload-repos-systemd/flatpak-sideload-usb-repo.path.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# have flatpaks on them, both when a new drive is inserted and at the start of
# the user session.
[Path]
PathExists=@media_dir@/%u
PathChanged=@media_dir@/%u

[Install]
Expand Down
3 changes: 3 additions & 0 deletions sideload-repos-systemd/flatpak-sideload-usb-repo.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
[Service]
Type=oneshot
ExecStart=@libexecdir@/flatpak-create-sideload-symlinks.sh @media_dir@/%u

[Install]
WantedBy=default.target

0 comments on commit c43e8e1

Please sign in to comment.