Skip to content

Commit ec59a76

Browse files
committed
nix-utils: replace is_valid_path with nix-bindings-store C API
1 parent 3864ebb commit ec59a76

3 files changed

Lines changed: 7 additions & 11 deletions

File tree

subprojects/crates/nix-utils/include/nix.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ rust::String get_build_dir();
2525
rust::String get_log_dir();
2626
rust::String get_state_dir();
2727

28-
bool is_valid_path(const StoreWrapper &wrapper, rust::Str path);
2928
InternalPathInfo query_path_info(const StoreWrapper &wrapper, rust::Str path);
3029
void clear_path_info_cache(const StoreWrapper &wrapper);
3130
uint64_t compute_closure_size(const StoreWrapper &wrapper, rust::Str path);

subprojects/crates/nix-utils/src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ mod ffi {
136136
fn get_log_dir() -> String;
137137
fn get_state_dir() -> String;
138138

139-
fn is_valid_path(store: &StoreWrapper, path: &str) -> Result<bool>;
140139
fn query_path_info(store: &StoreWrapper, path: &str) -> Result<InternalPathInfo>;
141140
fn compute_closure_size(store: &StoreWrapper, path: &str) -> Result<u64>;
142141
fn clear_path_info_cache(store: &StoreWrapper) -> Result<()>;
@@ -551,11 +550,14 @@ where
551550
impl BaseStore for BaseStoreImpl {
552551
#[inline]
553552
async fn is_valid_path(&self, path: &StorePath) -> bool {
554-
let store = self.wrapper.clone();
555553
let path = self.print_store_path(path);
556-
asyncify(move || ffi::is_valid_path(store.as_raw(), &path))
557-
.await
558-
.unwrap_or(false)
554+
asyncify_anyhow(move || -> Result<bool, Error> {
555+
let mut nbs = open_nbs_store()?;
556+
let nbs_path = nbs.parse_store_path(&path).map_err(Error::Anyhow)?;
557+
Ok(nbs.is_valid_path(&nbs_path))
558+
})
559+
.await
560+
.unwrap_or(false)
559561
}
560562

561563
#[inline]

subprojects/crates/nix-utils/src/nix.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ rust::String get_build_dir() {
6565
rust::String get_log_dir() { return nix::settings.getLogFileSettings().nixLogDir.string(); }
6666
rust::String get_state_dir() { return nix::settings.nixStateDir.string(); }
6767

68-
bool is_valid_path(const StoreWrapper &wrapper, rust::Str path) {
69-
auto store = wrapper._store;
70-
return store->isValidPath(store->parseStorePath(AS_VIEW(path)));
71-
}
72-
7368
InternalPathInfo query_path_info(const StoreWrapper &wrapper, rust::Str path) {
7469
auto store = wrapper._store;
7570
auto info = store->queryPathInfo(store->parseStorePath(AS_VIEW(path)));

0 commit comments

Comments
 (0)