From c68bd984abc2537ee32904960953dc57d97ef015 Mon Sep 17 00:00:00 2001 From: Joshua Cannon Date: Thu, 10 Nov 2022 11:38:34 -0600 Subject: [PATCH 1/4] oopsie --- src/rust/engine/fs/store/src/snapshot_ops.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rust/engine/fs/store/src/snapshot_ops.rs b/src/rust/engine/fs/store/src/snapshot_ops.rs index 43c900efda9..1105d9a14f9 100644 --- a/src/rust/engine/fs/store/src/snapshot_ops.rs +++ b/src/rust/engine/fs/store/src/snapshot_ops.rs @@ -58,7 +58,6 @@ async fn merge_directories( Ok(tree.into()) } - /// /// Render a directory::MergeError (or fail with a less specific error if some content cannot be /// loaded). @@ -229,7 +228,7 @@ pub trait SnapshotOps: Clone + Send + Sync + 'static { ) -> Result { let input_tree = self.load_digest_trie(directory_digest.clone()).await?; let path_stats = input_tree - .expand_globs(params.globs, SymlinkBehavior::Oblivious, None) + .expand_globs(params.globs, SymlinkBehavior::Aware, None) .await .map_err(|err| format!("Error matching globs against {directory_digest:?}: {}", err))?; @@ -238,7 +237,7 @@ pub trait SnapshotOps: Clone + Send + Sync + 'static { directory::Entry::File(f) => { files.insert(path.to_owned(), f.digest()); } - directory::Entry::Symlink(_) => todo!(), + directory::Entry::Symlink(_) => (), directory::Entry::Directory(_) => (), }); From 64e119c44370a825de0cd9fce37ae7bc42920ee9 Mon Sep 17 00:00:00 2001 From: Joshua Cannon Date: Thu, 10 Nov 2022 11:39:34 -0600 Subject: [PATCH 2/4] n --- src/rust/engine/fs/store/src/snapshot_ops.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rust/engine/fs/store/src/snapshot_ops.rs b/src/rust/engine/fs/store/src/snapshot_ops.rs index 1105d9a14f9..2ff58db4210 100644 --- a/src/rust/engine/fs/store/src/snapshot_ops.rs +++ b/src/rust/engine/fs/store/src/snapshot_ops.rs @@ -58,6 +58,7 @@ async fn merge_directories( Ok(tree.into()) } + /// /// Render a directory::MergeError (or fail with a less specific error if some content cannot be /// loaded). From 844fe0e1193da282e9693833364b8a8c45bd5eed Mon Sep 17 00:00:00 2001 From: Joshua Cannon Date: Thu, 10 Nov 2022 15:34:14 -0600 Subject: [PATCH 3/4] always oblivious --- src/rust/engine/fs/store/src/snapshot_ops.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rust/engine/fs/store/src/snapshot_ops.rs b/src/rust/engine/fs/store/src/snapshot_ops.rs index 2ff58db4210..dbb137810a8 100644 --- a/src/rust/engine/fs/store/src/snapshot_ops.rs +++ b/src/rust/engine/fs/store/src/snapshot_ops.rs @@ -229,16 +229,16 @@ pub trait SnapshotOps: Clone + Send + Sync + 'static { ) -> Result { let input_tree = self.load_digest_trie(directory_digest.clone()).await?; let path_stats = input_tree - .expand_globs(params.globs, SymlinkBehavior::Aware, None) + .expand_globs(params.globs, SymlinkBehavior::Oblivious, None) .await .map_err(|err| format!("Error matching globs against {directory_digest:?}: {}", err))?; let mut files = HashMap::new(); - input_tree.walk(SymlinkBehavior::Aware, &mut |path, entry| match entry { + input_tree.walk(SymlinkBehavior::Oblivious, &mut |path, entry| match entry { directory::Entry::File(f) => { files.insert(path.to_owned(), f.digest()); } - directory::Entry::Symlink(_) => (), + directory::Entry::Symlink(_) => panic!("Unexpected symlink"), directory::Entry::Directory(_) => (), }); From d262c49ef4dbfca348cb93c741556dde4a60fdb4 Mon Sep 17 00:00:00 2001 From: Joshua Cannon Date: Fri, 11 Nov 2022 10:44:20 -0600 Subject: [PATCH 4/4] comment --- src/python/pants/engine/fs.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/python/pants/engine/fs.py b/src/python/pants/engine/fs.py index 9bfe326904c..9c1422020b6 100644 --- a/src/python/pants/engine/fs.py +++ b/src/python/pants/engine/fs.py @@ -222,6 +222,10 @@ class PathGlobsAndRoot: class DigestSubset: """A request to get a subset of a digest. + The digest will be traversed symlink-oblivious to match the provided globs. If you require a + symlink-aware subset, you can access the digest's entries `Get(DigestEntries, Digest, digest)`, + filter them out, and create a new digest: `Get(Digest, CreateDigest(...))`. + Example: result = await Get(Digest, DigestSubset(original_digest, PathGlobs(["subdir1", "f.txt"]))