fix: auto-rename on duplicate filename conflict#197
Merged
MaojiaSheng merged 1 commit intovolcengine:mainfrom Feb 17, 2026
Merged
fix: auto-rename on duplicate filename conflict#197MaojiaSheng merged 1 commit intovolcengine:mainfrom
MaojiaSheng merged 1 commit intovolcengine:mainfrom
Conversation
When uploading a file with the same name as an existing resource, TreeBuilder.finalize_from_temp() now auto-appends _1, _2, ... suffix instead of crashing with a 409 Conflict from AGFS mkdir. Root cause: finalize_from_temp built the final URI directly from the source filename without checking whether a resource at that URI already existed. The subsequent mkdir() call (without exist_ok=True) failed when the directory was already present. Fix: Add _resolve_unique_uri() that checks via stat() and finds the first available name, similar to macOS Finder / Windows Explorer behavior. Closes volcengine#178
Contributor
Author
|
Hi, I've signed the CLA and the workflow is awaiting approval. |
MaojiaSheng
approved these changes
Feb 17, 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.
Problem
Closes #178
Uploading a file with the same name as an existing resource (e.g. uploading
report.pdftwice) causes a 409 Conflict error from AGFSmkdir. This is especially problematic in multi-user (account) scenarios.Root cause:
TreeBuilder.finalize_from_temp()builds the final URI directly from the source filename without checking whether a resource at that URI already exists. The subsequentmkdir()call (withoutexist_ok=True) fails when the directory is already present.Solution
Added
_resolve_unique_uri()toTreeBuilderthat:stat()_1,_2, … until a free name is foundExample: uploading
report.pdfthree times produces:viking://resources/reportviking://resources/report_1viking://resources/report_2Changes
openviking/parse/tree_builder.py: Added_resolve_unique_uri()method; updatedfinalize_from_temp()to use ittests/misc/test_tree_builder_dedup.py: 5 new unit tests covering no-conflict, single conflict, multiple conflicts, max-attempts exceeded, and gap-in-sequence scenariosTesting