Skip to content

Follow symlinks when building bundle #546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 1 addition & 27 deletions rsconnect/bundle.py
Original file line number Diff line number Diff line change
@@ -498,32 +498,6 @@ def write_manifest(
return created, skipped


def list_files(base_dir, include_sub_dirs, walk=os.walk):
"""List the files in the directory at path.

If include_sub_dirs is True, recursively list
files in subdirectories.

Returns an iterable of file paths relative to base_dir.
"""
skip_dirs = [".ipynb_checkpoints", ".git"]

def iter_files():
for root, sub_dirs, files in walk(base_dir):
if include_sub_dirs:
for skip in skip_dirs:
if skip in sub_dirs:
sub_dirs.remove(skip)
else:
# tell walk not to traverse any subdirectories
sub_dirs[:] = []

for filename in files:
yield relpath(join(root, filename), base_dir)

return list(iter_files())


def make_notebook_source_bundle(
file: str,
environment: Environment,
@@ -1038,7 +1012,7 @@ def create_file_list(
file_set.add(path_to_add)
return sorted(file_set)

for cur_dir, sub_dirs, files in os.walk(path):
for cur_dir, sub_dirs, files in os.walk(path, followlinks=True):
if Path(cur_dir) in exclude_paths:
continue
if any(parent in exclude_paths for parent in Path(cur_dir).parents):
36 changes: 0 additions & 36 deletions tests/test_bundle.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@
create_python_environment,
get_python_env_info,
inspect_environment,
list_files,
make_api_bundle,
make_api_manifest,
make_html_bundle,
@@ -427,41 +426,6 @@ def test_make_quarto_source_bundle_from_file(self):
},
)

def test_list_files(self):
# noinspection SpellCheckingInspection
paths = [
"notebook.ipynb",
"somedata.csv",
os.path.join("subdir", "subfile"),
os.path.join("subdir2", "subfile2"),
os.path.join(".ipynb_checkpoints", "notebook.ipynb"),
os.path.join(".git", "config"),
]

def walk(base_dir):
dir_names = []
file_names = []

for path in paths:
if os.sep in path:
dir_name, file_name = path.split(os.sep, 1)
dir_names.append(dir_name)
else:
file_names.append(path)

yield base_dir, dir_names, file_names

for subdir in dir_names:
for path in paths:
if path.startswith(subdir + os.sep):
yield base_dir + os.sep + subdir, [], [path.split(os.sep, 1)[1]]

files = list_files(".", True, walk=walk)
self.assertEqual(files, paths[:4])

files = list_files(os.sep, False, walk=walk)
self.assertEqual(files, paths[:2])

def test_html_bundle1(self):
self.do_test_html_bundle(get_dir("pip1"))