Skip to content

Commit 8de3e2d

Browse files
committed
1. 修复博客地址配置错误
2. 修复进度条打印失败的问题。删掉不必要的日志
1 parent 463a0ce commit 8de3e2d

5 files changed

Lines changed: 41 additions & 30 deletions

File tree

.vscode/launch.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,20 @@
1616
"env": {
1717
"HF_ENDPOINT": "https://hf-mirror.com"
1818
},
19-
"args": "--verbose --git-batch=true --tag-count=3 --tag-method=keybert"
19+
"args": "--verbose --git-batch=true --tag-count=0 --tag-method=keybert"
20+
},
21+
{
22+
"name": "Python数据同步 (.venv)",
23+
"type": "debugpy",
24+
"request": "launch",
25+
"cwd": "${workspaceFolder}",
26+
"program": "${file}",
27+
"console": "integratedTerminal",
28+
"python": "${workspaceFolder}/.venv/bin/python",
29+
"env": {
30+
"HF_ENDPOINT": "https://hf-mirror.com"
31+
},
32+
"args": "--verbose"
2033
},
2134
{
2235
"name": "Python数据处理 (uv run + attach)",

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
- [ ] 工程化指南
5353
- [TODO] ~~将数据处理的脚本,整理为python的模块。~~
5454
- [x] 通过.env定义环境变量和参数。给出.env.example文件,给出参数说明。.env本身不要提交到git中。
55-
- [TODO] README.md 包括项目说明、快速开始。
55+
- [x] README.md 包括项目说明、快速开始。
5656

5757
CICI 流水线的过程。Github Actions流水线-> Dockerfile镜像构建 -> build.sh 构建脚本 -> uv/npm构建工具 -> python和nodejs工程。
5858
1. notes工程开发

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ timezone: 'Asia/Shanghai'
1313

1414
# URL
1515
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
16-
url: https://estom.github.com
16+
url: https://estom.github.io
1717
# root: /hexo-blog/
1818
permalink: :year/:month/:day/:title/
1919
permalink_defaults:

docker.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# 基础镜像没有变化,不需要每次重新构建
22
# docker build -t ghcr.io/estom/hexo-blog:base-v1.0.0 -f Dockerfile-base .
33
# docker push ghcr.io/estom/hexo-blog:base-v1.0.0
4-
docker build -t ghcr.io/estom/hexo-blog:build-v1.0.0 -f Dockerfile-build .
5-
docker push ghcr.io/estom/hexo-blog:build-v1.0.0
6-
docker build -t ghcr.io/estom/hexo-blog:run-v1.0.0 -f Dockerfile-runtime .
7-
docker push ghcr.io/estom/hexo-blog:run-v1.0.0
4+
# docker build -t hexo-blog:build-v1.0.0 -f Dockerfile-build .
5+
# docker push hexo-blog:build-v1.0.0
6+
docker build -t hexo-blog:run-v1.0.0 -f Dockerfile .
7+
# docker push hexo-blog:run-v1.0.0
88

99
# 运行基础镜像
10-
docker run -d --name notes -p 80:80 ghcr.io/estom/hexo-blog:run-v1.0.0
10+
docker run -d --name notes -p 80:80 hexo-blog:run-v1.0.0
1111

1212
# 本地启动hexo 服务器。不适用docker打包的方式
1313
# nohup hexo server -p 4001 > hexo.log 2&>1 &
@@ -18,4 +18,4 @@ docker run -d --name notes -p 80:80 ghcr.io/estom/hexo-blog:run-v1.0.0
1818

1919
# 更新子模块,会触发子模块的下载
2020
# git submodule update --recursive
21-
uv run hexo-proc --verbose --git-batch=true --tag-method=keybert --tag-count=3 --tag-budget=100
21+
# uv run hexo-proc --verbose --git-batch=true --tag-method=keybert --tag-count=3 --tag-budget=100

processor/proc.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ class ProgressPrinter:
5858

5959
def __post_init__(self) -> None:
6060
if not self.enabled:
61-
self._is_tty = False
6261
return
6362
self._is_tty = bool(getattr(self.tty_stream, "isatty", lambda: False)())
63+
print(f"[tags] enabled: {self.enabled},is_tty: {self._is_tty}")
6464

6565
def _render_bar(self, done: int, total: int) -> str:
6666
if total <= 0:
@@ -861,8 +861,8 @@ def _build_git_time_index(repo_dir: Path, interest_paths: Set[str], date_kind: s
861861
created: Dict[str, int] = {}
862862
done: Set[str] = set()
863863
current_ts: Optional[int] = None
864-
progress = ProgressPrinter(enabled=verbose, prefix='[git] batch')
865-
last_filled = -1
864+
progress = ProgressPrinter(enabled=verbose, prefix='[git] scan')
865+
total_lines = 0
866866

867867
try:
868868
with tempfile.NamedTemporaryFile(prefix='git-log-', suffix='.txt', delete=False, mode='w', encoding='utf-8') as fp:
@@ -888,8 +888,14 @@ def _build_git_time_index(repo_dir: Path, interest_paths: Set[str], date_kind: s
888888

889889
if out_path is None:
890890
return {}
891+
892+
# Progress: use processed line count / total line count.
893+
# Only compute total_lines when verbose to avoid an extra full pass.
894+
with open(out_path, 'r', encoding='utf-8', errors='replace') as f_total:
895+
total_lines = sum(1 for _ in f_total)
896+
891897
with open(out_path, 'r', encoding='utf-8', errors='replace') as f:
892-
for line in f:
898+
for line_no, line in enumerate(f, start=1):
893899
s = line.rstrip('\n')
894900
if not s:
895901
continue
@@ -903,6 +909,8 @@ def _build_git_time_index(repo_dir: Path, interest_paths: Set[str], date_kind: s
903909
continue
904910

905911
parts = s.split('\t')
912+
if len(parts) < 2:
913+
continue
906914
status = parts[0]
907915
# Rename: Rxxx\told\tnew
908916
if status.startswith('R') and len(parts) >= 3:
@@ -921,8 +929,7 @@ def _build_git_time_index(repo_dir: Path, interest_paths: Set[str], date_kind: s
921929
created[final] = current_ts
922930
continue
923931

924-
if len(parts) < 2:
925-
continue
932+
926933
path = parts[1]
927934
if path in interest_paths:
928935
final = path
@@ -933,18 +940,8 @@ def _build_git_time_index(repo_dir: Path, interest_paths: Set[str], date_kind: s
933940

934941
updated.setdefault(final, current_ts)
935942
created[final] = current_ts
936-
if status == 'A':
937-
done.add(final)
938-
if len(done) == len(interest_paths):
939-
break
940-
941-
filled = 0
942-
for k in interest_paths:
943-
if k in updated and k in created:
944-
filled += 1
945-
if filled != last_filled:
946-
progress.update(filled, len(interest_paths))
947-
last_filled = filled
943+
# Throttle progress updates to reduce TTY overhead.
944+
progress.update(line_no, total_lines)
948945
finally:
949946
if out_path:
950947
try:
@@ -958,7 +955,8 @@ def _build_git_time_index(repo_dir: Path, interest_paths: Set[str], date_kind: s
958955
u = updated.get(k)
959956
if c is not None and u is not None:
960957
result[k] = (c, u)
961-
progress.close(len(interest_paths))
958+
# Mark progress completed (even if we early-stopped).
959+
progress.close(total_lines)
962960
return result
963961

964962

@@ -1128,8 +1126,8 @@ def process_directory(cfg: ProcessConfig) -> int:
11281126
for i, p in enumerate(files, start=1):
11291127
if process_file(cfg, p):
11301128
count += 1
1131-
if cfg.verbose:
1132-
print(f"[ok] {p.relative_to(cfg.target_dir).as_posix()}")
1129+
# if cfg.verbose:
1130+
# print(f"[ok] {p.relative_to(cfg.target_dir).as_posix()}")
11331131
progress.update(i, total)
11341132
progress.close(total)
11351133

0 commit comments

Comments
 (0)