diff --git a/rsconnect/bundle.py b/rsconnect/bundle.py index ad7770fe..31209523 100644 --- a/rsconnect/bundle.py +++ b/rsconnect/bundle.py @@ -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): diff --git a/tests/test_bundle.py b/tests/test_bundle.py index cc8f5bcd..1c977e23 100644 --- a/tests/test_bundle.py +++ b/tests/test_bundle.py @@ -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"))