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

refactor: megfile sync #491

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

refactor: megfile sync #491

wants to merge 2 commits into from

Conversation

bbtfr
Copy link
Member

@bbtfr bbtfr commented Jan 25, 2025

  1. 每个文件拷贝完打印一下完成,可以通过 --verbose 开启
  2. 扫描文件改为在线程里完成,这样可以边扫边拷,对大量小文件比较友好
image

Copy link

codecov bot commented Jan 25, 2025

Codecov Report

Attention: Patch coverage is 95.23810% with 2 lines in your changes missing coverage. Please review.

Project coverage is 99.95%. Comparing base (7be020a) to head (8086eb7).

Files with missing lines Patch % Lines
megfile/cli.py 94.87% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #491      +/-   ##
==========================================
- Coverage   99.98%   99.95%   -0.04%     
==========================================
  Files          44       44              
  Lines        6391     6409      +18     
==========================================
+ Hits         6390     6406      +16     
- Misses          1        3       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bbtfr bbtfr force-pushed the liyang/megfile-sync-print-more branch from f3c7407 to a221c73 Compare January 25, 2025 03:46
@@ -69,10 +71,13 @@ def cli(debug, log_level):


def safe_cli(): # pragma: no cover
debug = options.get("debug", False)
if not debug:
signal.signal(signal.SIGINT, signal.SIG_DFL)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加上这句使得 Ctrl+C 总是能立刻关掉任务
CLI 里有些地方很多地方用了多线程,Ctrl+C 半天关不掉

)
@click.option("-G", "--no-progress-bar", is_flag=True, help="Do not show progress bar.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里有个不向前兼容更新,把 --progress-bar 改成 --no-progress-bar
之前这个设成啥都会有进度条,只是有没有 total 的区别,感觉有歧义

@@ -404,7 +404,7 @@ def _smart_sync_single_file(items: dict):
force = items["force"]
overwrite = items["overwrite"]

content_path = os.path.relpath(src_file_path, start=src_root_path)
content_path = smart_relpath(src_file_path, start=src_root_path)
Copy link
Member Author

@bbtfr bbtfr Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是个 bugfix,不用 smart_relpath 会导致 alias 拼路径拼错

@@ -438,6 +438,8 @@ def _smart_sync_single_file(items: dict):
callback=copy_callback,
followlinks=followlinks,
)
elif callback:
callback(src_file_path, src_file_stat.size)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

跳过的文件也能在进度条上体现

@bbtfr bbtfr force-pushed the liyang/megfile-sync-print-more branch 2 times, most recently from d1f66bb to 574a659 Compare January 25, 2025 03:54
@bbtfr bbtfr force-pushed the liyang/megfile-sync-print-more branch 2 times, most recently from ae8c450 to 8f848c4 Compare January 25, 2025 04:11
@bbtfr bbtfr force-pushed the liyang/megfile-sync-print-more branch from 8f848c4 to 8086eb7 Compare January 25, 2025 04:13
@bbtfr bbtfr changed the title megfile sync print more details refactor: megfile sync Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant