From cfefaddf142d540034295d5713fb2cdea44b8bbc Mon Sep 17 00:00:00 2001 From: r0chd Date: Mon, 5 Oct 2026 17:40:22 +0200 Subject: [PATCH] ci: improvements --- .tangled/workflows/check.yaml | 33 ++-- .tangled/workflows/clippy.yaml | 31 ++-- .tangled/workflows/fmt.yaml | 7 +- .tangled/workflows/test.yaml | 40 ++--- .tangled/workflows/vm-tests.yaml | 40 +++++ default.nix | 2 +- flake.nix | 6 +- libsession-sys/src/lib.rs | 30 ++++ lon.lock | 15 ++ lon.nix | 41 +++++ nix/internal/nixos-checks.nix | 3 +- nix/internal/shell.nix | 2 +- npins/default.nix | 260 ------------------------------- npins/sources.json | 18 --- sessiond/src/consolekit.rs | 12 +- 15 files changed, 179 insertions(+), 361 deletions(-) create mode 100644 .tangled/workflows/vm-tests.yaml create mode 100644 lon.lock create mode 100644 lon.nix delete mode 100644 npins/default.nix delete mode 100644 npins/sources.json diff --git a/.tangled/workflows/check.yaml b/.tangled/workflows/check.yaml index 371579c..11e0efa 100644 --- a/.tangled/workflows/check.yaml +++ b/.tangled/workflows/check.yaml @@ -8,35 +8,30 @@ engine: nixery environment: PKG_CONFIG_PATH: /lib/pkgconfig:/share/pkgconfig + LIBRARY_PATH: /lib + RUSTFLAGS: "-L native=/lib" + RUSTDOCFLAGS: "-L native=/lib" + LD_LIBRARY_PATH: /lib dependencies: nixpkgs: - rustup - gcc - - linux-pam - pkg-config - - libudev-zero - - acl + - linux-pam.out + - udev.out + - udev.dev + - acl.out + - acl.dev steps: - name: cargo check command: | + set -eu rustup toolchain install stable rustup default stable + pkg-config --libs --cflags pam libudev libsystemd libacl - cargo build -p libsession - - mkdir -p target/pkgconfig - sed \ - -e "s|@PREFIX@|$(pwd)|" \ - -e "s|@INCLUDE@|$(pwd)/libsession/include|" \ - -e "s|@LIBDIR@|$(pwd)/target/debug|" \ - -e 's|@LIBSESSION_VERSION@|0.0.0|' \ - libsession/libsession.pc.in > target/pkgconfig/libsession.pc - export PKG_CONFIG_PATH="$(pwd)/target/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" - pkg-config --libs --cflags libudev - - cargo check --workspace --all-features - cargo check --manifest-path sessiond-backlight/Cargo.toml - cargo check --manifest-path sessiond-hooks/Cargo.toml - cargo check --manifest-path sessiond-uaccess/Cargo.toml + # libsession is not part of the daemon release checks yet. + cargo check --locked --workspace --exclude libsession-sys --exclude libsession-rs --all-targets --no-default-features + cargo check --locked --workspace --exclude libsession-sys --exclude libsession-rs --all-targets --all-features diff --git a/.tangled/workflows/clippy.yaml b/.tangled/workflows/clippy.yaml index 57f0834..175aca0 100644 --- a/.tangled/workflows/clippy.yaml +++ b/.tangled/workflows/clippy.yaml @@ -8,36 +8,29 @@ engine: nixery environment: PKG_CONFIG_PATH: /lib/pkgconfig:/share/pkgconfig + LIBRARY_PATH: /lib + RUSTFLAGS: "-L native=/lib" + RUSTDOCFLAGS: "-L native=/lib" + LD_LIBRARY_PATH: /lib dependencies: nixpkgs: - rustup - gcc - - linux-pam - pkg-config - - libudev-zero - - acl + - linux-pam.out + - udev.out + - udev.dev + - acl.out + - acl.dev steps: - name: cargo clippy command: | + set -eu rustup toolchain install stable rustup default stable rustup component add clippy + pkg-config --libs --cflags pam libudev libsystemd libacl - cargo build -p libsession - - mkdir -p target/pkgconfig - sed \ - -e "s|@PREFIX@|$(pwd)|" \ - -e "s|@INCLUDE@|$(pwd)/libsession/include|" \ - -e "s|@LIBDIR@|$(pwd)/target/debug|" \ - -e 's|@LIBSESSION_VERSION@|0.0.0|' \ - libsession/libsession.pc.in > target/pkgconfig/libsession.pc - export PKG_CONFIG_PATH="$(pwd)/target/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" - pkg-config --libs --cflags libudev - - cargo clippy --workspace --all-features -- -D warnings - cargo clippy --manifest-path sessiond-backlight/Cargo.toml -- -D warnings - cargo clippy --manifest-path sessiond-hooks/Cargo.toml -- -D warnings - cargo clippy --manifest-path sessiond-uaccess/Cargo.toml -- -D warnings + cargo clippy --locked --workspace --all-targets --all-features -- -D warnings diff --git a/.tangled/workflows/fmt.yaml b/.tangled/workflows/fmt.yaml index 6f49699..813f252 100644 --- a/.tangled/workflows/fmt.yaml +++ b/.tangled/workflows/fmt.yaml @@ -16,15 +16,14 @@ dependencies: steps: - name: nix fmt command: | + set -eu fd -t f -e nix -x nixfmt --check '{}' fd -t f -e toml -x taplo fmt --check '{}' - name: cargo fmt command: | + set -eu rustup toolchain install stable rustup default stable rustup component add rustfmt - cargo fmt --check - cargo fmt --manifest-path sessiond-backlight/Cargo.toml --check - cargo fmt --manifest-path sessiond-hooks/Cargo.toml --check - cargo fmt --manifest-path sessiond-uaccess/Cargo.toml --check + cargo fmt --all --check diff --git a/.tangled/workflows/test.yaml b/.tangled/workflows/test.yaml index 3cb769b..dd04c94 100644 --- a/.tangled/workflows/test.yaml +++ b/.tangled/workflows/test.yaml @@ -8,43 +8,29 @@ engine: nixery environment: PKG_CONFIG_PATH: /lib/pkgconfig:/share/pkgconfig + LIBRARY_PATH: /lib + RUSTFLAGS: "-L native=/lib" + RUSTDOCFLAGS: "-L native=/lib" + LD_LIBRARY_PATH: /lib dependencies: nixpkgs: - rustup - gcc - - linux-pam - pkg-config - - nix - - libudev-zero - - acl + - linux-pam.out + - udev.out + - udev.dev + - acl.out + - acl.dev steps: - name: cargo test command: | + set -eu rustup toolchain install stable rustup default stable - pkg-config --libs --cflags libudev - cargo build --package sessiond - cargo test --package sessiond - cargo test --manifest-path sessiond-backlight/Cargo.toml - cargo test --manifest-path sessiond-hooks/Cargo.toml - cargo test --manifest-path sessiond-uaccess/Cargo.toml - cargo test --package sessiond-power - cargo test --package sessiond-power-client - cargo test --package sessiond-rebootctl - cargo test --package sessiond-poweroffctl - cargo test --package sessiond-suspendctl - cargo test --package sessiond-hibernatectl + pkg-config --libs --cflags pam libudev libsystemd libacl - - name: finix vm tests - command: | - nix --extra-experimental-features 'nix-command flakes' --option system-features 'benchmark big-parallel nixos-test uid-range kvm' build -L .#checks.x86_64-linux.finix-basic - nix --extra-experimental-features 'nix-command flakes' --option system-features 'benchmark big-parallel nixos-test uid-range kvm' build -L .#checks.x86_64-linux.finix-vt-switch - nix --extra-experimental-features 'nix-command flakes' --option system-features 'benchmark big-parallel nixos-test uid-range kvm' build -L .#checks.x86_64-linux.finix-termination - nix --extra-experimental-features 'nix-command flakes' --option system-features 'benchmark big-parallel nixos-test uid-range kvm' build -L .#checks.x86_64-linux.finix-linger - nix --extra-experimental-features 'nix-command flakes' --option system-features 'benchmark big-parallel nixos-test uid-range kvm' build -L .#checks.x86_64-linux.finix-state-recovery - - - name: nixos vm tests - command: | - nix --extra-experimental-features 'nix-command flakes' --option system-features 'benchmark big-parallel nixos-test uid-range kvm' build -L .#checks.x86_64-linux.nixos-basic + cargo test --locked --workspace --exclude libsession-sys --exclude libsession-rs --no-default-features + cargo test --locked --workspace --exclude libsession-sys --exclude libsession-rs --all-features diff --git a/.tangled/workflows/vm-tests.yaml b/.tangled/workflows/vm-tests.yaml new file mode 100644 index 0000000..a54cb47 --- /dev/null +++ b/.tangled/workflows/vm-tests.yaml @@ -0,0 +1,40 @@ +when: + - event: ["push", "manual"] + branch: ["*"] + - event: ["pull_request"] + branch: ["master"] + +engine: nixery + +# The spindle must expose KVM and allow enough time for cold Nix builds. +# Its timeout is configured by the spindle operator, not in this workflow. +environment: + NIX_CONFIG: | + experimental-features = nix-command flakes + system-features = benchmark big-parallel nixos-test uid-range kvm + +dependencies: + nixpkgs: + - nix + +steps: + - name: finix basic + command: nix build --no-link -L .#checks.x86_64-linux.finix-basic + + - name: finix vt switch + command: nix build --no-link -L .#checks.x86_64-linux.finix-vt-switch + + - name: finix termination + command: nix build --no-link -L .#checks.x86_64-linux.finix-termination + + - name: finix linger + command: nix build --no-link -L .#checks.x86_64-linux.finix-linger + + - name: finix consolekit + command: nix build --no-link -L .#checks.x86_64-linux.finix-consolekit + + - name: finix state recovery + command: nix build --no-link -L .#checks.x86_64-linux.finix-state-recovery + + - name: nixos basic + command: nix build --no-link -L .#checks.x86_64-linux.nixos-basic diff --git a/default.nix b/default.nix index be4e347..d8b77d1 100644 --- a/default.nix +++ b/default.nix @@ -3,7 +3,7 @@ system = builtins.currentSystem; }, craneLib ? import (import ./nix/internal/flake-parse.nix "crane") { inherit pkgs; }, - finix ? (import ./npins).finix, + finix ? (import ./lon.nix).finix, }: let src = pkgs.lib.cleanSourceWith { diff --git a/flake.nix b/flake.nix index 0fd991a..33b601b 100644 --- a/flake.nix +++ b/flake.nix @@ -17,7 +17,7 @@ "aarch64-linux" ]; - sources = import ./npins; + sources = import ./lon.nix; pkgsFor = system: @@ -30,8 +30,8 @@ forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f (pkgsFor system)); - finix = (import sources.finix.outPath) // { - inherit (sources.finix) outPath; + finix = (import sources.finix) // { + outPath = sources.finix; }; in { diff --git a/libsession-sys/src/lib.rs b/libsession-sys/src/lib.rs index 0935fb9..a0f9416 100644 --- a/libsession-sys/src/lib.rs +++ b/libsession-sys/src/lib.rs @@ -20,6 +20,7 @@ struct Libsession { } #[allow(non_camel_case_types)] +#[repr(C)] pub struct libsession_context { _private: [u8; 0], } @@ -338,6 +339,14 @@ pub unsafe extern "C" fn libsession_session_is_active( LibsessionStatus::Ok } +/// Reports whether a session is local. +/// +/// # Safety +/// +/// Non-null `ctx` must be a live context with exclusive access for this call. +/// Non-null `session` must point to a valid NUL-terminated string for this call. +/// Non-null `ret_local` must point to writable, aligned storage that does not +/// overlap the context or session string. It is written only on success. #[unsafe(no_mangle)] pub unsafe extern "C" fn libsession_session_is_local( ctx: *mut libsession_context, @@ -361,6 +370,7 @@ pub unsafe extern "C" fn libsession_session_is_local( } #[allow(non_camel_case_types)] +#[repr(C)] pub struct libsession_monitor { _private: [u8; 0], } @@ -411,6 +421,14 @@ pub extern "C" fn libsession_monitor_fd(monitor: *mut libsession_monitor) -> ffi pub type LibsessionLogFn = Option; +/// Sets the context's logging callback, or disables callbacks with `None`. +/// +/// # Safety +/// +/// Non-null `ctx` must be a live context on the thread that created it. +/// The callback must remain callable until replaced or the context is freed. +/// It must not unwind, access the context reentrantly, or retain the message +/// pointer, which is valid only for the duration of the callback. #[unsafe(no_mangle)] pub unsafe extern "C" fn libsession_set_log_fn( ctx: *mut libsession_context, @@ -438,6 +456,12 @@ pub enum LibsessionLogLevel { Trace = 5, } +/// Sets the context's logging level. +/// +/// # Safety +/// +/// Non-null `ctx` must be a live context on the thread that created it and +/// remain valid for this call. #[unsafe(no_mangle)] pub unsafe extern "C" fn libsession_set_log_level( ctx: *mut libsession_context, @@ -453,6 +477,12 @@ pub unsafe extern "C" fn libsession_set_log_level( LibsessionStatus::Ok } +/// Retrieves the context's logging level. +/// +/// # Safety +/// +/// Non-null `ctx` must be a live context on the thread that created it and +/// remain valid for this call. #[unsafe(no_mangle)] pub unsafe extern "C" fn libsession_get_log_level( ctx: *const libsession_context, diff --git a/lon.lock b/lon.lock new file mode 100644 index 0000000..663f0e3 --- /dev/null +++ b/lon.lock @@ -0,0 +1,15 @@ +{ + "version": "1", + "sources": { + "finix": { + "type": "GitHub", + "fetchType": "tarball", + "owner": "finix-community", + "repo": "finix", + "branch": "main", + "revision": "c6acbb9697a0a50ab578e957cd002e15c4f31674", + "url": "https://github.com/finix-community/finix/archive/c6acbb9697a0a50ab578e957cd002e15c4f31674.tar.gz", + "hash": "sha256-uD3jOjGE9sSUIJINitmirHB/qj6cucJ8f/hlFn3MxMQ=" + } + } +} diff --git a/lon.nix b/lon.nix new file mode 100644 index 0000000..3a4671f --- /dev/null +++ b/lon.nix @@ -0,0 +1,41 @@ +# SPDX-FileCopyrightText: 2026 lon contributors +# +# SPDX-License-Identifier: MIT + +# Generated by lon. Do not modify! +let + lock = builtins.fromJSON (builtins.readFile ./lon.lock); + + overrideFromEnv = + name: path: + let + replacement = builtins.getEnv "LON_OVERRIDE_${name}"; + in + if replacement == "" then + path + else if builtins.substring 0 1 replacement == "/" then + /. + replacement + else + /. + builtins.getEnv "PWD" + "/${replacement}"; + + fetchSource = + args@{ fetchType, ... }: + if fetchType == "git" then + fetchGit { + url = args.url; + ref = args.branch; + rev = args.revision; + narHash = args.hash; + submodules = args.submodules; + lastModified = args.lastModified; + shallow = true; + } + else if fetchType == "tarball" then + fetchTarball { + url = args.url; + sha256 = args.hash; + } + else + throw "Unsupported source type ${fetchType}"; +in +builtins.mapAttrs (name: args: overrideFromEnv name (fetchSource args)) lock.sources diff --git a/nix/internal/nixos-checks.nix b/nix/internal/nixos-checks.nix index 9d89388..599359f 100644 --- a/nix/internal/nixos-checks.nix +++ b/nix/internal/nixos-checks.nix @@ -5,7 +5,8 @@ }: let sessiondPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.sessiond; - sessiondTest = test: + sessiondTest = + test: pkgs.testers.nixosTest ( test // { diff --git a/nix/internal/shell.nix b/nix/internal/shell.nix index 403a310..4198455 100644 --- a/nix/internal/shell.nix +++ b/nix/internal/shell.nix @@ -10,7 +10,7 @@ craneLib.devShell { inherit (pkgs) rust-analyzer-unwrapped nixd - npins + lon linux-pam pkg-config udev diff --git a/npins/default.nix b/npins/default.nix deleted file mode 100644 index 8ec5eca..0000000 --- a/npins/default.nix +++ /dev/null @@ -1,260 +0,0 @@ -/* - This file is provided under the MIT licence: - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -# Generated by npins. Do not modify; will be overwritten regularly -let - # Backwards-compatibly make something that previously didn't take any arguments take some - # The function must return an attrset, and will unfortunately be eagerly evaluated - # Same thing, but it catches eval errors on the default argument so that one may still call it with other arguments - mkFunctor = - fn: - let - e = builtins.tryEval (fn { }); - in - (if e.success then e.value else { error = fn { }; }) // { __functor = _self: fn; }; - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 - range = - first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 - stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 - stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatStrings = builtins.concatStringsSep ""; - - # If the environment variable NPINS_OVERRIDE_${name} is set, then use - # the path directly as opposed to the fetched source. - # (Taken from Niv for compatibility) - mayOverride = - name: path: - let - envVarName = "NPINS_OVERRIDE_${saneName}"; - saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name; - ersatz = builtins.getEnv envVarName; - in - if ersatz == "" then - path - else - # this turns the string into an actual Nix path (for both absolute and - # relative paths) - builtins.trace "Overriding path of \"${name}\" with \"${ersatz}\" due to set \"${envVarName}\"" ( - if builtins.substring 0 1 ersatz == "/" then - /. + ersatz - else - /. + builtins.getEnv "PWD" + "/${ersatz}" - ); - - mkSource = - name: spec: - { - pkgs ? null, - }: - assert spec ? type; - let - # Unify across builtin and pkgs fetchers. - # `fetchGit` requires a wrapper because of slight API differences. - fetchers = - if pkgs == null then - { - inherit (builtins) fetchTarball fetchurl; - # Frustratingly, due to flakes and `fetchTree`, `fetchGit` - # has a different signature than the other builtin - # fetchers - fetchGit = args: (builtins.fetchGit args).outPath; - } - else - { - fetchTarball = - { - url, - sha256, - }: - pkgs.fetchzip { - inherit url sha256; - extension = "tar"; - }; - inherit (pkgs) fetchurl; - fetchGit = - { - url, - submodules, - rev, - name, - narHash, - }: - pkgs.fetchgit { - inherit url rev name; - fetchSubmodules = submodules; - hash = narHash; - }; - }; - - path = - if spec.type == "Git" then - mkGitSource fetchers spec - else if spec.type == "GitRelease" then - mkGitSource fetchers spec - else if spec.type == "PyPi" then - mkPyPiSource fetchers spec - else if spec.type == "Channel" then - mkChannelSource fetchers spec - else if spec.type == "Url" || spec.type == "MutableUrl" then - mkUrlSource fetchers spec - else if spec.type == "Container" then - mkContainerSource pkgs spec - else - builtins.throw "Unknown source type ${spec.type}"; - in - spec // { outPath = mayOverride name path; }; - - mkGitSource = - { - fetchTarball, - fetchGit, - ... - }: - { - repository, - revision, - url ? null, - submodules, - hash, - ... - }: - assert repository ? type; - # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository - # In the latter case, there we will always be an url to the tarball - if url != null && !submodules then - fetchTarball { - inherit url; - sha256 = hash; - } - else - let - url = - if repository.type == "Git" then - repository.url - else if repository.type == "GitHub" then - "https://github.com/${repository.owner}/${repository.repo}.git" - else if repository.type == "GitLab" then - "${repository.server}/${repository.repo_path}.git" - else if repository.type == "Forgejo" then - "${repository.server}/${repository.owner}/${repository.repo}.git" - else - throw "Unrecognized repository type ${repository.type}"; - urlToName = - url: rev: - let - matched = builtins.match "^.*/([^/]*)(\\.git)?$" url; - - short = builtins.substring 0 7 rev; - - appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else ""; - in - "${if matched == null then "source" else builtins.head matched}${appendShort}"; - name = urlToName url revision; - in - fetchGit { - rev = revision; - narHash = hash; - - inherit name submodules url; - }; - - mkPyPiSource = - { fetchurl, ... }: - { - url, - hash, - ... - }: - fetchurl { - inherit url; - sha256 = hash; - }; - - mkChannelSource = - { fetchTarball, ... }: - { - url, - hash, - ... - }: - fetchTarball { - inherit url; - sha256 = hash; - }; - - mkUrlSource = - { - fetchTarball, - fetchurl, - ... - }: - { - url, - hash, - unpack, - ... - }: - (if unpack then fetchTarball else fetchurl) { - inherit url; - sha256 = hash; - }; - - mkContainerSource = - pkgs: - { - image_name, - image_tag, - image_digest, - hash, - ... - }@args: - if pkgs == null then - builtins.throw "container sources require passing in a Nixpkgs value: https://github.com/andir/npins/blob/master/README.md#using-the-nixpkgs-fetchers" - else - pkgs.dockerTools.pullImage ( - { - imageName = image_name; - imageDigest = image_digest; - finalImageTag = image_tag; - hash = hash; - } - // (if args.arch or null != null then { arch = args.arch; } else { }) - ); - -in -mkFunctor ( - { - input ? ./sources.json, - }: - let - data = - if builtins.isPath input then - # while `readFile` will throw an error anyways if the path doesn't exist, - # we still need to check beforehand because *our* error can be caught but not the one from the builtin - # See: - if builtins.pathExists input then - builtins.fromJSON (builtins.readFile input) - else - throw "Input path ${toString input} does not exist" - else if builtins.isAttrs input then - input - else - throw "Unsupported input type ${builtins.typeOf input}, must be a path or an attrset"; - version = data.version; - in - if version == 8 then - builtins.mapAttrs (name: spec: mkFunctor (mkSource name spec)) data.pins - else - throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" -) diff --git a/npins/sources.json b/npins/sources.json deleted file mode 100644 index 8c275ef..0000000 --- a/npins/sources.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "pins": { - "finix": { - "type": "Git", - "repository": { - "type": "GitHub", - "owner": "finix-community", - "repo": "finix" - }, - "branch": "main", - "submodules": false, - "revision": "37c6c49aac1ba686fc7b4def599e6a0a7e3ef0bc", - "url": "https://github.com/finix-community/finix/archive/37c6c49aac1ba686fc7b4def599e6a0a7e3ef0bc.tar.gz", - "hash": "sha256-0Js5CxesLCEriPZaNBGW84Cz0BODBVR7ZKlEqZZ5ayE=" - } - }, - "version": 8 -} diff --git a/sessiond/src/consolekit.rs b/sessiond/src/consolekit.rs index e61c85f..bd04b24 100644 --- a/sessiond/src/consolekit.rs +++ b/sessiond/src/consolekit.rs @@ -282,10 +282,6 @@ fn apply_command(connection: Option<&blocking::Connection>, state: &SharedState, if should_register && let Some(connection) = connection { register_session(connection, state, id); } - - if let Err(err) = write_database(state) { - log::warn!(error = err.to_string().as_str(); "failed to write ConsoleKit database"); - } } Command::Remove(id) => { if let Ok(mut state) = state.write() { @@ -298,12 +294,12 @@ fn apply_command(connection: Option<&blocking::Connection>, state: &SharedState, log::debug!(session_id = id, error = err.to_string().as_str(); "failed to unregister ConsoleKit session object"); } } - - if let Err(err) = write_database(state) { - log::warn!(error = err.to_string().as_str(); "failed to write ConsoleKit database"); - } } } + + if let Err(err) = write_database(state) { + log::warn!(error = err.to_string().as_str(); "failed to write ConsoleKit database"); + } } fn register_session(connection: &blocking::Connection, state: &SharedState, id: u32) { -- 2.51.2