Skip to content

Conversation

ids1024
Copy link
Member

@ids1024 ids1024 commented Aug 22, 2025

It looks like this was changed to be like this in cd8f4ee. But key_path() only seems to return Error::NoConfigDirectory or Error::InvalidName, so it seems reasonable to just update get() to also check for NoConfigDirectory. (get_local() doesn't seem to be used elsewhere, so I don't see nay issues this can cause.)

It's also a bit odd that get_default() doesn't map errors to NotFound. I guess is_err() should return true if the default config doesn't exist, since (at least for some settings) it's important to have default configurations present? But then get_system_default() could return NoConfigDirectory from the .default_path() call, which has the same issue...

Also, maybe using is_file(), then reading the file, is racy. Not that it should matter that much, but just checking for not found errors from the read_to_string call is probably sufficient.

Leaving as a draft while considering these other issues.

It looks like this was changed to be like this in cd8f4ee. But
`key_path()` only seems to return `Error::NoConfigDirectory` or
`Error::InvalidName`, so it seems reasonable to just update `get()` to
also check for `NoConfigDirectory`. (`get_local()` doesn't seem
to be used elsewhere, so I don't see nay issues this can cause.)
ids1024 added a commit to pop-os/cosmic-settings-daemon that referenced this pull request Aug 22, 2025
As noted in pop-os/cosmic-comp#1603, there's no
need to a system default config file for this particular setting. So as
an alternative to that PR, we can ensure this isn't printed as an error.

As noted in the description of
pop-os/libcosmic#948, if the system default is
not present, `Error::GetKey` is returned, without mapping to the
`Error::NotFound` variant. So check for that, as well as `.is_err()`.
ids1024 added a commit that referenced this pull request Aug 22, 2025
Like pop-os/cosmic-settings-daemon#100. We don't
appear to install default configs for these settings anywhere? And we
may not want libcosmic to inherently depend on globally installed config
files.

So just avoid printing errors in that case.

We may want to consider what errors `ConfigGet` returns
(#948) but this should do for
now.

This should help with a big part of the log spam libcosmic is currently
producing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant