Skip to content

fix: use normalized path in ClassifiedFile for cross-platform consistency#574

Merged
qin-ctx merged 1 commit intovolcengine:mainfrom
sponge225:fix/issue-540
Mar 13, 2026
Merged

fix: use normalized path in ClassifiedFile for cross-platform consistency#574
qin-ctx merged 1 commit intovolcengine:mainfrom
sponge225:fix/issue-540

Conversation

@sponge225
Copy link
Copy Markdown
Contributor

@sponge225 sponge225 commented Mar 13, 2026

Description

When creating ClassifiedFile objects in directory_scan.py, the unnormalized rel_path was used instead of the already-computed rel_path_norm. This caused inconsistent path formats on Windows systems (backslashes vs forward slashes).

directory_scan.py 中创建 ClassifiedFile 对象时,使用了未规范化的 rel_path 而不是已经计算好的 rel_path_norm。这导致 Windows 系统上的路径格式不一致(反斜杠与正斜杠混用)。

Solution

Changed line 272 to use rel_path_norm instead of rel_path:

修改第 272 行,使用 rel_path_norm 替代 rel_path

# Before / 修改前
classified = ClassifiedFile(
    path=file_path, rel_path=rel_path, classification=classification
)

# After / 修改后
classified = ClassifiedFile(
    path=file_path, rel_path=rel_path_norm, classification=classification
)

Related Issue

fixed #540

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

Testing

The fix has been verified with a mocked Windows path integration test. The test uses PureWindowsPath to simulate Windows-style path separators and confirms that directory structure is preserved correctly.

此修复已通过模拟 Windows 路径的集成测试验证。测试使用 PureWindowsPath 模拟 Windows 风格的路径分隔符,确认目录结构被正确保留。

🔗 Test Script: test_issue_540.py

run python test_issue_540.py

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Additional Notes

@qin-ctx qin-ctx merged commit adf4d92 into volcengine:main Mar 13, 2026
5 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 13, 2026
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: add_resource无法保留层级目录,同名文件会丢失

3 participants