rename from_path to from_derivation
This commit is contained in:
parent
878e096494
commit
54d4c714af
3 changed files with 18 additions and 14 deletions
|
@ -22,19 +22,19 @@ pub struct PathInfo {
|
|||
}
|
||||
|
||||
impl PathInfo {
|
||||
pub async fn from_path(path: &Path, store: &Store) -> Result<Self> {
|
||||
debug!("query path info for {:?}", path);
|
||||
pub async fn from_derivation(drv: &Path, store: &Store) -> Result<Self> {
|
||||
debug!("query path info for {:?}", drv);
|
||||
|
||||
let derivation = match path.extension() {
|
||||
Some(ext) if ext == "drv" => path.as_os_str().as_encoded_bytes(),
|
||||
let derivation = match drv.extension() {
|
||||
Some(ext) if ext == "drv" => drv.as_os_str().as_encoded_bytes(),
|
||||
_ => {
|
||||
&Command::new("nix")
|
||||
.arg("path-info")
|
||||
.arg("--derivation")
|
||||
.arg(path)
|
||||
.arg(drv)
|
||||
.output()
|
||||
.await
|
||||
.context(format!("run command: nix path-info --derivaiton {path:?}"))?
|
||||
.context(format!("run command: nix path-info --derivaiton {drv:?}"))?
|
||||
.stdout
|
||||
}
|
||||
};
|
||||
|
@ -43,16 +43,20 @@ impl PathInfo {
|
|||
|
||||
if derivation.is_empty() {
|
||||
return Err(anyhow!(
|
||||
"nix path-info did not return a derivation for {path:#?}"
|
||||
"nix path-info did not return a derivation for {drv:#?}"
|
||||
));
|
||||
}
|
||||
|
||||
let store_path = StorePath::from_absolute_path(derivation.trim().as_bytes())
|
||||
.context("storepath from derivation")?;
|
||||
Self::from_path(derivation.trim(), store).await
|
||||
}
|
||||
|
||||
pub async fn from_path(path: &str, store: &Store) -> Result<Self> {
|
||||
let store_path =
|
||||
StorePath::from_absolute_path(path.as_bytes()).context("storepath from path")?;
|
||||
store
|
||||
.query_path_info(store_path)
|
||||
.await
|
||||
.context("query pathinfo for derivation")
|
||||
.context("query pathinfo for path")
|
||||
}
|
||||
|
||||
pub async fn get_closure(&self, store: &Store) -> Result<Vec<Self>> {
|
||||
|
|
|
@ -79,7 +79,7 @@ impl Push {
|
|||
let store = self.store.clone();
|
||||
|
||||
futs.push(tokio::spawn(async move {
|
||||
let path_info = PathInfo::from_path(path.as_path(), &store)
|
||||
let path_info = PathInfo::from_derivation(path.as_path(), &store)
|
||||
.await
|
||||
.context("get path info for path")?;
|
||||
debug!("path-info for {path:?}: {path_info:?}");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue