diff --git a/flytekit/types/directory/types.py b/flytekit/types/directory/types.py index a7c0aacc83..fa77a75e98 100644 --- a/flytekit/types/directory/types.py +++ b/flytekit/types/directory/types.py @@ -367,10 +367,11 @@ def listdir(cls, directory: FlyteDirectory) -> typing.List[typing.Union[FlyteDir file_access = FlyteContextManager.current_context().file_access if not file_access.is_remote(final_path): for p in os.listdir(final_path): - if os.path.isfile(os.path.join(final_path, p)): - paths.append(FlyteFile(p)) + joined_path = os.path.join(final_path, p) + if os.path.isfile(joined_path): + paths.append(FlyteFile(joined_path)) else: - paths.append(FlyteDirectory(p)) + paths.append(FlyteDirectory(joined_path)) return paths def create_downloader(_remote_path: str, _local_path: str, is_multipart: bool):