Fix detection of symlinked Cargo.tomls

This commit fixes a bug introduced in #276 where symlinked Cargo.tomls
wouldn't get detected due to readDir() reporting them as - well -
_symlinks_ instead of regular files.

Note that we continue to keep the `if type == "directory"` condition for
recursion which means that we'll fail to detect "nested" Cargo.tomls if
someone decides to go wild and create workspace with symlinked crates.

That I'm not 100% sure on how to approach, but fortunately cases like
those seem to be practically non-existent (and Crane apparently not
supporting them builds a bit of confidence here as well).

Closes #280.
This commit is contained in:
Patryk Wychowaniec 2023-03-22 20:59:35 +01:00
parent 5c8dbab3d9
commit 88cd223801
6 changed files with 24 additions and 1 deletions

View file

@ -306,7 +306,7 @@ let
path = "${root}/${dir}/${name}";
in
if type == "regular" && name == "Cargo.toml" then
if name == "Cargo.toml" then
[{ name = dir; toml = readTOML path; }]
else if type == "directory" then
findCargoTomls "${dir}/${name}"

View file

@ -13,6 +13,7 @@ args: {
readme = import ./readme args;
simple-dep = import ./simple-dep args;
simple-dep-patched = import ./simple-dep-patched args;
symlinks = import ./symlinks args;
workspace = import ./workspace args;
workspace-build-rs = import ./workspace-build-rs args;
workspace-patched = import ./workspace-patched args;

View file

@ -0,0 +1,8 @@
{ naersk, pkgs, ... }: {
default = naersk.buildPackage {
src = pkgs.symlinkJoin {
name = "src";
paths = [ ./fixtures ];
};
};
}

7
test/fast/symlinks/fixtures/Cargo.lock generated Normal file
View file

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "app"
version = "0.1.0"

View file

@ -0,0 +1,4 @@
[package]
name = "app"
version = "0.1.0"
edition = "2018"

View file

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}