From 0907420600ba0f9270065dd83e81fb8f56dfda71 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 9 Dec 2023 12:48:24 +0200 Subject: refactor(nix-compat/store_path): from_absolute_path to StorePathRef The only non-test usage was only checking for the error case, and we can still convert this to an owned StorePath by calling to_owned() on StorePathRef. Change-Id: I9f67a759e580c9c429c96896bcdd295392aa5a2a Reviewed-on: https://cl.tvl.fyi/c/depot/+/10225 Reviewed-by: tazjin Autosubmit: flokli Tested-by: BuildkiteCI --- tvix/nix-compat/src/derivation/output.rs | 4 ++-- tvix/nix-compat/src/derivation/validate.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tvix/nix-compat/src/derivation') diff --git a/tvix/nix-compat/src/derivation/output.rs b/tvix/nix-compat/src/derivation/output.rs index c13f94859dc1..b7fa1ac379b0 100644 --- a/tvix/nix-compat/src/derivation/output.rs +++ b/tvix/nix-compat/src/derivation/output.rs @@ -1,6 +1,6 @@ use crate::derivation::OutputError; use crate::nixhash::CAHash; -use crate::store_path::StorePath; +use crate::store_path::StorePathRef; use serde::{Deserialize, Serialize}; use serde_json::Map; @@ -51,7 +51,7 @@ impl Output { } if validate_output_paths { - if let Err(e) = StorePath::from_absolute_path(self.path.as_bytes()) { + if let Err(e) = StorePathRef::from_absolute_path(self.path.as_bytes()) { return Err(OutputError::InvalidOutputPath(self.path.to_string(), e)); } } diff --git a/tvix/nix-compat/src/derivation/validate.rs b/tvix/nix-compat/src/derivation/validate.rs index 37ddf9017138..b88df1f621cd 100644 --- a/tvix/nix-compat/src/derivation/validate.rs +++ b/tvix/nix-compat/src/derivation/validate.rs @@ -1,5 +1,5 @@ use crate::derivation::{Derivation, DerivationError}; -use crate::store_path::{self, StorePath}; +use crate::store_path::{self, StorePathRef}; impl Derivation { /// validate ensures a Derivation struct is properly populated, @@ -53,7 +53,7 @@ impl Derivation { // Validate all input_derivations for (input_derivation_path, output_names) in &self.input_derivations { // Validate input_derivation_path - if let Err(e) = StorePath::from_absolute_path(input_derivation_path.as_bytes()) { + if let Err(e) = StorePathRef::from_absolute_path(input_derivation_path.as_bytes()) { return Err(DerivationError::InvalidInputDerivationPath( input_derivation_path.to_string(), e, @@ -96,7 +96,7 @@ impl Derivation { // Validate all input_sources for input_source in self.input_sources.iter() { - if let Err(e) = StorePath::from_absolute_path(input_source.as_bytes()) { + if let Err(e) = StorePathRef::from_absolute_path(input_source.as_bytes()) { return Err(DerivationError::InvalidInputSourcesPath( input_source.to_string(), e, -- cgit 1.4.1