don't check canonicalized paths while sandboxed

Because the configured paths won't exist in the sandbox, so
canonicalization would fail.
This commit is contained in:
Charles Hall 2025-03-21 15:22:14 -07:00
parent 50583bc93e
commit a04951541a
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
5 changed files with 30 additions and 19 deletions

View file

@ -514,7 +514,10 @@ fn search() -> Result<PathBuf, error::ConfigSearch> {
}
/// Load the configuration from the given path or XDG Base Directories
pub(crate) async fn load<P>(path: Option<P>) -> Result<Config, error::Config>
pub(crate) async fn load<P>(
path: Option<P>,
sandboxed: bool,
) -> Result<Config, error::Config>
where
P: AsRef<Path>,
{
@ -544,18 +547,20 @@ where
return Err(Error::DatabaseMediaOverlap);
}
let media_path = x
.path
.canonicalize()
.map_err(|e| Error::Canonicalize(e, x.path.clone()))?;
if !sandboxed {
let media_path = x
.path
.canonicalize()
.map_err(|e| Error::Canonicalize(e, x.path.clone()))?;
let database_path =
config.database.path.canonicalize().map_err(|e| {
Error::Canonicalize(e, config.database.path.clone())
})?;
let database_path =
config.database.path.canonicalize().map_err(|e| {
Error::Canonicalize(e, config.database.path.clone())
})?;
if overlap(&media_path, &database_path) {
return Err(Error::DatabaseMediaOverlap);
if overlap(&media_path, &database_path) {
return Err(Error::DatabaseMediaOverlap);
}
}
}
}