mirror of
https://github.com/NixOS/nix
synced 2025-06-28 05:21:16 +02:00
StorePath::new(): Check store directory
This commit is contained in:
parent
410acd29c0
commit
14d82baba4
3 changed files with 10 additions and 3 deletions
|
@ -13,8 +13,10 @@ pub const STORE_PATH_HASH_BYTES: usize = 20;
|
|||
pub const STORE_PATH_HASH_CHARS: usize = 32;
|
||||
|
||||
impl StorePath {
|
||||
pub fn new(path: &Path, _store_dir: &str) -> Result<Self, Error> {
|
||||
// FIXME: check store_dir
|
||||
pub fn new(path: &Path, store_dir: &Path) -> Result<Self, Error> {
|
||||
if path.parent() != Some(store_dir) {
|
||||
return Err(Error::NotInStore(path.into()));
|
||||
}
|
||||
Self::new_from_base_name(
|
||||
path.file_name()
|
||||
.ok_or(Error::BadStorePath(path.into()))?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue