Skip to content

fix: infoharbor_ex.code 存在但不可读时回退占位符,不中断同步#44

Merged
xbfighting merged 1 commit into
masterfrom
fix-infoharbor-eperm
Jul 7, 2026
Merged

fix: infoharbor_ex.code 存在但不可读时回退占位符,不中断同步#44
xbfighting merged 1 commit into
masterfrom
fix-infoharbor-eperm

Conversation

@xbfighting

Copy link
Copy Markdown
Owner

问题

#43 引入的 _load_real_names() 只处理了名称文件缺失的场景(exists() 为假 → 警告 + 占位符回退)。当文件存在但不可读时——实测场景:SMB 挂载会话劣化返回 EPERM;Windows 端通达信运行中锁定 hq_cache 亦同——read_text() 抛出的 OSError 无人捕获,直接中断整个 daily/minutes 同步。

股票名称是可选增强,daily/minutes 同步仅用 get_stock_list() 枚举代码,不依赖名称,不应因此失败。

修复

读取包上 try/except OSError,与文件缺失走同一条降级路径:警告日志 + 返回空 dict(get_stock_list 回退占位符命名)。

测试

  • 新增 test_fallback_placeholder_when_file_unreadable:chmod 000 模拟不可读 → 回退占位符不抛异常(Windows 上 chmod 权限位无效,skipif 跳过)
  • pytest tests/test_reader.py 10 passed
  • 实机验证:EPERM 场景下 daily 同步继续执行并输出降级警告(2026-07-07 SMB 会话劣化实测)

🤖 Generated with Claude Code

SMB 挂载下运行中的通达信会锁定 hq_cache 文件(EPERM),
_load_real_names 只兜了文件缺失,read_text 抛 OSError 直接
中断 daily/minutes 同步。现与缺失场景同样降级处理。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@xbfighting
xbfighting merged commit 3a70f04 into master Jul 7, 2026
5 checks passed
@xbfighting
xbfighting deleted the fix-infoharbor-eperm branch July 7, 2026 16:00
xbfighting added a commit that referenced this pull request Jul 7, 2026
* feat: 股本/上市日期入库 + 换手率支持 (#45, closes #1)

- stock_info 新增 zgb/ltag(万股)、capital_date/list_date,
  来自 base.dbf(ZGB/LTAG/GXRQ/SSDATE),缺失/不可读降级 NULL
- 换手率(%) = daily_data.volume / stock_info.ltag(手 与 万股
  单位差恰好抵消;实测平安 0.547%/茅台 0.328% 与行情软件同量级)
- save_stock_info 改单事务快照替换(append 重跑撞 code 唯一约束)
- parse_base_dbf 通用化(按列名取值),parse_base_dbf_dy 改为薄封装
- blocks 四链文件读取统一补缺失/不可读降级(#44 同款场景)
- 迁移脚本 migrate_stock_info_capital.sql;测试 +4(含目录冒充文件
  触发 OSError 的跨平台降级测试)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: 换手率 FAQ/SQL 与股本列说明(README/AGENTS/skill)(#45)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: _try_parse 补捕获 ValueError + 快照替换测试(review 修复)

- blocks 链的格式异常(如 base.dbf 缺列)改为单链降级,
  不再传播丢弃已收集的其他链结果
- 测试 +2:缺列 DBF 仅地区链降级 / save_stock_info 快照替换与失败回滚

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
xbfighting added a commit that referenced this pull request Jul 8, 2026
股本/换手率支持(#45)、stock_info 真实名称(#42)、
SMB 锁定文件降级(#44)、blocks 链降级加固

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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