Abort/hold execution of a program, if not in sync

This is probably better being a 3rd-party thing. I’m planning to write something like this; does anything like it exist already?

The main point is to sync applications, normally single-user. Problem being, that partial syncs and 2 devices running/starting the same program at once can result in a bad state.

thoughts proceed, optionally ignore

Locking looks like this:

  1. Instead of execing the executable, the locking middleware is executed.
  2. It checks, if¹:
    1. A specific folder is up to date
    2. Other device(s) are alive
      1. If the device shows up as disconnected in ST, fail? Try to SSH in to the device(s)? Check last seen date? Ask the user, if the other computer is fenced (so, not up without network) or at least the process is not running.
    3. There are any locks (restic-style: timestamped expiry)
    4. SSH in to the device(s) to confirm once again, that the process in question is not running.
  3. Create a lock, switch folder to send-only
  4. Remove the lock, switch to receive-only, or send-receive, depending on the folder.

Locking and confirmations done with a basic requests server instead?

Conflict resolution? Abort on conflicts? Make a restic backup before switching out of send-only?

¹ Not quite sure on how to perform the checking here. In theory, I have an always-online node as well. (For better or worse, can’t use Nextcloud for some of the processes.) Fail if not connected to the always-online node? Must be connected or last seen above d?

You could achieve this by calling syncthing cli or using the REST API and reacting appropriately, as well as searching for syncthing.*.tmp files (incomplete syncs), but Syncthing is best suited for purposes where the synchronisation is automatic and continuous.