Skip to main content

acquire

Function acquire 

Source
pub(crate) fn acquire(
    config_dir: &Path,
    app_support: &Path,
) -> Result<Option<File>, AcquireError>
Expand description

Acquire the per-config-dir single-instance lock under app_support.

The caller resolves the base, so a test can pass a tempdir and never write to the real app-support directory. In production that base is forge_sdk::app_support_dir, which keeps the lock out of the Syncthing-synced config dir (see the module docs).

On success the returned File MUST be held for the process lifetime; dropping it (or process exit / crash) releases the flock, so there is no stale-lock cleanup. Ok(None) is the degraded path: the lock dir couldn’t be created, the lockfile couldn’t be opened, or the filesystem rejected flock, so forge boots without the guarantee rather than refusing over an exotic FS (the local APFS/ext4 the user runs always supports flock). Err means another forge instance already owns this config dir.