feat(parse): extract shared upload utilities#87
Merged
MaojiaSheng merged 1 commit intovolcengine:mainfrom Feb 7, 2026
Merged
Conversation
Extract encoding detection and file upload logic from CodeRepositoryParser._upload_directory() into a new shared module openviking/parse/parsers/upload_utils.py for reuse by the upcoming DirectoryParser (Issue volcengine#80, Discussion volcengine#83 T2). Shared functions: is_text_file, detect_and_convert_encoding, should_skip_file, should_skip_directory, upload_text_files, upload_directory, with OS-independent path traversal protection. CodeRepositoryParser._upload_directory now delegates to the shared upload_directory function (108 lines -> 3 lines). Includes 52 test cases covering all functions and edge cases.
MaojiaSheng
approved these changes
Feb 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extract encoding detection and file upload logic from
CodeRepositoryParser._upload_directory()into a new shared moduleopenviking/parse/parsers/upload_utils.pyfor reuse by the upcoming DirectoryParser (Issue #80, Discussion #83 T2).Related Issue
Relates to #80
Discussion #83 (T2: shared upload utilities)
Type of Change
Changes Made
openviking/parse/parsers/upload_utils.pywith shared functions:is_text_file,detect_and_convert_encoding,should_skip_file,should_skip_directory,upload_text_files,upload_directory, with OS-independent path traversal protection via_sanitize_rel_pathCodeRepositoryParser._upload_directory()from 108-line inline implementation to 3-line delegation to sharedupload_directorycode.py(ADDITIONAL_TEXT_EXTENSIONS,TEXT_ENCODINGS,UTF8_VARIANTS)Testing
52 test cases covering all functions and edge cases (path traversal, encoding conversion, file filtering, upload failures, etc.)
Checklist
Additional Notes
This PR is the T2 sub-task from Discussion #83 (DirectoryParser RFC), providing shared infrastructure for the upcoming T3/T5 implementations.