Skip to content

Commit

Permalink
feat: update default worker for megfile sync (#489)
Browse files Browse the repository at this point in the history
Co-authored-by: liyang <[email protected]>
  • Loading branch information
bbtfr and liyang authored Jan 24, 2025
1 parent 24a39f2 commit 7be020a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions megfile/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def rm(path: str, recursive: bool):
@click.argument("dst_path")
@click.option("-g", "--progress-bar", is_flag=True, help="Show progress bar.")
@click.option(
"-w", "--worker", type=click.INT, default=8, help="Number of concurrent workers."
"-w", "--worker", type=click.INT, default=-1, help="Number of concurrent workers."
)
@click.option(
"-f", "--force", is_flag=True, help="Copy files forcible, ignore same files."
Expand All @@ -388,7 +388,8 @@ def sync(
if not smart_exists(dst_path):
force = True

with ThreadPoolExecutor(max_workers=worker) as executor:
max_workers = worker if worker > 0 else (os.cpu_count() or 1) * 2
with ThreadPoolExecutor(max_workers=max_workers) as executor:
if has_magic(src_path):
src_root_path = get_non_glob_dir(src_path)
if not smart_exists(src_root_path):
Expand Down

0 comments on commit 7be020a

Please sign in to comment.