diff --git a/src/neuro_flow/expr.py b/src/neuro_flow/expr.py index 520d754b..fa0d9658 100644 --- a/src/neuro_flow/expr.py +++ b/src/neuro_flow/expr.py @@ -292,6 +292,8 @@ async def hash_files_relative(ctx: CallCtx, root: LocalPath, *patterns: str) -> # resolve() restores the case. relative_fname = fname.resolve().relative_to(root.resolve()).as_posix() hasher.update(relative_fname.encode("utf-8")) + if not fname.is_file(): + continue with fname.open("rb", buffering=0) as stream: read = stream.readinto(buffer) while read: diff --git a/tests/unit/hash_files/requirements/.hidden-dir/something.txt b/tests/unit/hash_files/requirements/.hidden-dir/something.txt new file mode 100644 index 00000000..19f0805d --- /dev/null +++ b/tests/unit/hash_files/requirements/.hidden-dir/something.txt @@ -0,0 +1 @@ +qwerty diff --git a/tests/unit/test_functions.py b/tests/unit/test_functions.py index 567df315..d9678335 100644 --- a/tests/unit/test_functions.py +++ b/tests/unit/test_functions.py @@ -128,10 +128,10 @@ async def test_fmt(client: Client) -> None: async def test_hash_files(client: Client) -> None: - expr = StrExpr(POS, POS, "${{ hash_files('Dockerfile', 'requirements/*.txt') }}") + expr = StrExpr(POS, POS, "${{ hash_files('Dockerfile', 'requirements/**/*') }}") folder = LocalPath(__file__).parent / "hash_files" ret = await expr.eval(Root({"flow": {"workspace": folder}}, client)) - assert ret == "081fde04651e1184890a0470501bff3db8e0014260224e07acf5688e70e0edbe" + assert ret == "a8174f2c445c954da64b20abbd4fce62e094cd95ba7344c13fba79f5037bcbe2" async def test_lower(client: Client) -> None: