Skip to content

Commit

Permalink
Updated error messages on recursive copy. (#125)
Browse files Browse the repository at this point in the history
Update the error messages to be more actionable when non-recursive
copying is attempted on directories.

---------

Co-authored-by: Hoyt Koepke <hoytak@xethub.com>
  • Loading branch information
Hoyt Koepke and Hoyt Koepke authored May 6, 2024
1 parent 7300c4b commit bb6b37d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions python/pyxet/pyxet/file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def _build_cp_action_list_impl(src_fs, src_path, dest_fs, dest_path, recursive,
# Handling directories. Make sure that the recursive flag is set.
if src_is_directory:
if not recursive:
print(f"{src_path} is a directory (not copied).")
print(f"Directory {src_path} skipped in non-recursive mode. Pass -r to enable recursive copying of directories.")
return


Expand Down Expand Up @@ -380,7 +380,9 @@ def perform_copy(source_list, destination, message = None, recursive=False):

if destproto_is_xet:
dest_fs.start_transaction(message)


any_copied = False

try:

# Get the list of everything to copy.
Expand All @@ -394,6 +396,8 @@ def perform_copy(source_list, destination, message = None, recursive=False):
for cp_action in _build_cp_action_list_impl(
src_fs, src_path, dest_fs, dest_path, recursive, progress_reporter):

any_copied = True

futures.append(executor.submit(_single_file_copy_impl, cp_action,
src_fs, dest_fs, progress_reporter))

Expand All @@ -408,4 +412,5 @@ def perform_copy(source_list, destination, message = None, recursive=False):
if destproto_is_xet:
dest_fs.end_transaction()

progress_reporter.finalize()
if any_copied:
progress_reporter.finalize()

0 comments on commit bb6b37d

Please sign in to comment.