From 7bd3c42c747498dea657e0ed26ed5ec2a9eddda3 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 5 Sep 2023 17:08:50 +0300 Subject: [PATCH] chore(tvix/store): drop walkdir workaround for symlinks at root https://github.com/BurntSushi/walkdir/pull/170 got merged, meaning we don't need to keep our own logic in here anymore. Our test cases already cover this. Change-Id: Ied3043ee651c8aafa10271c1e1ca5d460fb6c0b8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9269 Autosubmit: flokli Tested-by: BuildkiteCI Reviewed-by: tazjin --- tvix/Cargo.lock | 4 ++-- tvix/Cargo.nix | 4 ++-- tvix/store/Cargo.toml | 2 +- tvix/store/src/import.rs | 24 ++++-------------------- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/tvix/Cargo.lock b/tvix/Cargo.lock index df9a214b7..f2c1891b7 100644 --- a/tvix/Cargo.lock +++ b/tvix/Cargo.lock @@ -2920,9 +2920,9 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", "winapi-util", diff --git a/tvix/Cargo.nix b/tvix/Cargo.nix index 2ca478167..750dee2bb 100644 --- a/tvix/Cargo.nix +++ b/tvix/Cargo.nix @@ -8658,9 +8658,9 @@ rec { }; "walkdir" = rec { crateName = "walkdir"; - version = "2.3.3"; + version = "2.4.0"; edition = "2018"; - sha256 = "16768hy32kcvghq7v4ci8llfjvdiwrwg6sj9nzcdiisnv9699prn"; + sha256 = "1vjl9fmfc4v8k9ald23qrpcbyb8dl1ynyq8d516cm537r1yqa7fp"; authors = [ "Andrew Gallant " ]; diff --git a/tvix/store/Cargo.toml b/tvix/store/Cargo.toml index cd7b3a9b3..0dcada31a 100644 --- a/tvix/store/Cargo.toml +++ b/tvix/store/Cargo.toml @@ -21,7 +21,7 @@ tokio = { version = "1.28.0", features = ["rt-multi-thread", "net"] } tonic = "0.8.2" tracing = "0.1.37" tracing-subscriber = { version = "0.3.16", features = ["json"] } -walkdir = "2.3.2" +walkdir = "2.4.0" tokio-util = { version = "0.7.8", features = ["io", "io-util"] } tower = "0.4.13" futures = "0.3.28" diff --git a/tvix/store/src/import.rs b/tvix/store/src/import.rs index cb645a6e2..cd3dc01cf 100644 --- a/tvix/store/src/import.rs +++ b/tvix/store/src/import.rs @@ -6,7 +6,6 @@ use std::sync::Arc; use std::{ collections::HashMap, fmt::Debug, - fs, fs::File, io, os::unix::prelude::PermissionsExt, @@ -130,6 +129,9 @@ fn process_entry( /// interacting with a [BlobService] and [DirectoryService]. /// It returns the root node or an error. /// +/// It does not follow symlinks at the root, they will be ingested as actual +/// symlinks. +/// /// It's not interacting with a /// [PathInfoService](crate::pathinfoservice::PathInfoService), it's up to the /// caller to possibly register it somewhere (and potentially rename it based on @@ -140,25 +142,6 @@ pub fn ingest_path + Debug>( directory_service: Arc, p: P, ) -> Result { - // Probe if the path points to a symlink. If it does, we process it manually, - // due to https://github.com/BurntSushi/walkdir/issues/175. - let symlink_metadata = fs::symlink_metadata(p.as_ref()) - .map_err(|e| Error::UnableToStat(p.as_ref().to_path_buf(), e))?; - if symlink_metadata.is_symlink() { - let target = std::fs::read_link(p.as_ref()) - .map_err(|e| Error::UnableToStat(p.as_ref().to_path_buf(), e))?; - return Ok(proto::node::Node::Symlink(proto::SymlinkNode { - name: p - .as_ref() - .file_name() - .unwrap_or_default() - .as_bytes() - .to_owned() - .into(), - target: target.as_os_str().as_bytes().to_vec().into(), - })); - } - let mut directories: HashMap = HashMap::default(); // TODO: pass this one instead? @@ -166,6 +149,7 @@ pub fn ingest_path + Debug>( for entry in WalkDir::new(p) .follow_links(false) + .follow_root_links(false) .contents_first(true) .sort_by_file_name() {