fix: skip directory walk for single file uploads#57
Conversation
When a single HTML file has no sibling web assets or common web asset subdirectories (assets/, css/, js/, etc.), zip only the file itself instead of walking the entire parent directory. This fixes timeouts and parse errors when the file is in a large directory like /home/user. Closes #55 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
发现遗漏 Summary经过对比 issue #55 的 spec 与实现代码,发现实现功能基本完整,但有 1 个 MEDIUM 严重度的遗漏。 MEDIUM
其余所有 spec 要求的功能(skip WalkDir for single file、 |
|
Condition: the 其他问题(非阻塞):
|
…ctory assets Address AI code review feedback: - Replace hasSiblingWebAssets + isWebAssetDir with simpler isSingleFileDir: only use fast path when directory has exactly one non-hidden web asset file and zero non-hidden subdirectories. Any subdirectory presence triggers the full WalkDir to prevent silent resource loss. - Pass []os.DirEntry to writeSingleFileEntry to avoid redundant ReadDir. - Add hidden file check in writeSingleFileEntry for consistency with writeDirEntries behavior. - Add regression test TestSubdirectoryWithAssetsStillWalks verifying that non-standard subdirectory names (src/, components/, etc.) are walked. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
无遗漏 分析将 issue #55 的 spec 与 PR 实现逐项对比后,确认所有功能均已完整实现: Spec 要求 1:Skip
|
|
可合并 总结PR 通过两次提交正确实现了单文件上传时跳过 阻塞项无 建议项
|




Summary
filepath.WalkDirwhen the entry file has no sibling web assets and no common web asset subdirectories (assets/, css/, js/, images/, etc.)hasSiblingWebAssets()check: counts web asset files and detects web asset subdirectorieswriteSingleFileEntry()for single-file fast path, avoiding full directory traversalwriteFullDirArchive→writeDirEntries, archive lifecycle managed bywriteZIPArchiveTestSingleFileSkipsWalkOnLargeDirectoryverifying only the entry file is archived when surrounded by 200 non-web filesRoot Cause
writeZIPArchivealways usedfilepath.WalkDironfilepath.Dir(entryFile). For a file like/home/user/report.html, this walks the entire home directory — thousands of files — even though only the single HTML file is relevant.Test plan
TestSendUploadsMultipartArchive— multi-file project withassets/subdir still walks correctlyTestSendOnlyIncludesWebAssetsInArchive— multiple web assets still filters correctlyTestWriteZIPArchiveSkipsPermissionDenied— single file + non-web subdir uses fast pathCloses #55
🤖 Generated with Claude Code