mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-19 00:31:24 +01:00
reject overlapping media and database paths
This commit is contained in:
parent
81a449d1d2
commit
b01b70fc20
20 changed files with 146 additions and 4 deletions
|
|
@ -538,5 +538,27 @@ where
|
|||
return Err(Error::RegistrationTokenEmpty);
|
||||
}
|
||||
|
||||
match &config.media.backend {
|
||||
MediaBackendConfig::Filesystem(x) => {
|
||||
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 overlap = media_path == database_path
|
||||
|| media_path.starts_with(&database_path)
|
||||
|| database_path.starts_with(&media_path);
|
||||
|
||||
if overlap {
|
||||
return Err(Error::DatabaseMediaOverlap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(config)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue