fix: prevent stale cache causing rename-on-source after copy#2505
Open
tide-wait wants to merge 3 commits into
Open
fix: prevent stale cache causing rename-on-source after copy#2505tide-wait wants to merge 3 commits into
tide-wait wants to merge 3 commits into
Conversation
Member
|
Could you please format the PR description using the template, run go fmt before submitting, and disclose any AI-generated contributions if applicable? We are currently working on clearer guidelines for AI-assisted contributions, so apologies for the inconvenience. Thanks for the contribution. |
When a driver implementing CopyResult returns the source object instead of the actual new copy (e.g. 115_open), the directory cache was populated without a Temp mask. Subsequent Rename operations using excludeTempObj=true would hit the stale cache entry carrying the source file ID, causing the rename to target the source file instead of the copy. This ensures all post-copy and post-move cache entries carry the Temp flag, allowing Rename and Move to correctly trigger a fresh list via the existing excludeTempObj mechanism.
The 115 Open API endpoint folder/get_info now returns the data field as a JSON array instead of a single object. The SDK (115-sdk-go v0.2.3) still unmarshals into a single struct, causing a "cannot unmarshal array" error. Catch this error in the driver Get method and return errs.NotSupport, which causes the upper-level op.Get to fall back to listing the parent directory to resolve the target object.
f8d79d3 to
43d0679
Compare
Author
|
@jyxjjj Thanks for the review. I've updated the PR description using the template, run |
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.
Summary / 摘要
Two fixes for the 115_open driver (Open API token-based 115 cloud storage):
1. Copy→Rename race condition — source file renamed instead of copy
When
115_open'sCopymethod returns the source object (the API does not return new file info), the directory cache ininternal/op/fs.gowas populated without aTempmask. Subsequent Rename operations usingexcludeTempObj=truewould hit the stale cache entry carrying the source file'sFileID, causing the rename to target the source instead of the copy. TheMovepath had the same vulnerability.Fix: Apply
Tempmask uniformly to all post-Copy and post-Move cache entries, so the existingexcludeTempObjmechanism correctly triggers a fresh API list during subsequent Rename/Move.2. Mkdir failure — GetFolderInfo JSON unmarshal error
The 115 Open API endpoint
folder/get_infonow returnsdataas a JSON array[{...}]instead of a single object{...}. The SDK (115-sdk-go v0.2.3) still unmarshals intoGetFolderInfoResp(a single struct), causingjson.Unmarshalto fail. Mkdir callsGet()to check existence, which hits this error.Fix: Catch the unmarshal error in the driver's
Getmethod and returnerrs.NotSupport, allowing the upper-levelop.Getto gracefully fall back to listing the parent directory.Changes
internal/op/fs.godrivers/115_open/driver.goGet(), returnerrs.NotSupport; adderrsimportRelated Issues / 关联 Issue
Fixes #2506
Testing / 测试
go build ./internal/op/ ./drivers/115_open/Checklist / 检查清单
gofmt,go fmt, orprettierwhere applicable.AI Disclosure / AI 使用声明
Tools used / 使用工具:
Usage scope / 使用范围:
Co-Authored-Byattribution.