Skip to content
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

Fix non-recursive rm deleting files in subdirectories #254

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion b2/_internal/console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2405,7 +2405,11 @@ def run(self) -> None:
self.messages_queue.put(self.END_MARKER)

def _run_removal(self, executor: Executor):
for file_version, _ in self.runner._get_ls_generator(self.args):
for file_version, subdirectory in self.runner._get_ls_generator(self.args):
if subdirectory is not None:
# This file_version is not for listing/deleting.
# It is only here to list the subdirectory, so skip deleting it.
continue
# Obtaining semaphore limits number of elements that we fetch from LS.
self.semaphore.acquire(blocking=True)
# This event is updated before the semaphore is released. This way,
Expand Down
2 changes: 2 additions & 0 deletions changelog.d/+fix-rm-non-recursive.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed a bug where `rm` command without the `--recursive` flag would
emnoor-reef marked this conversation as resolved.
Show resolved Hide resolved
remove a file from every subdirectory inside `folderName`.
3 changes: 3 additions & 0 deletions test/unit/test_console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2599,6 +2599,9 @@ def test_rm_no_recursive(self):
expected_stdout = '''
a/test.csv
a/test.tsv
b/b/test.csv
b/b1/test.csv
b/b2/test.tsv
c/test.csv
c/test.tsv
'''
Expand Down
Loading