fix(aliyundrive_open): resolve file duplication issues and improve path handling#8358
Merged
xhofe merged 3 commits intoAlistGo:mainfrom Apr 19, 2025
Merged
fix(aliyundrive_open): resolve file duplication issues and improve path handling#8358xhofe merged 3 commits intoAlistGo:mainfrom
xhofe merged 3 commits intoAlistGo:mainfrom
Conversation
…th handling 1. Fix file duplication by implementing a new removeDuplicateFiles method that cleans up duplicate files after operations 2. Change Move operation to use "ignore" for check_name_mode instead of "refuse" to allow moves when destination has same filename 3. Set Copy operation to handle duplicates by removing them after successful copy 4. Improve path handling for all file operations (Move, Rename, Put, MakeDir) by properly maintaining the full path of objects 5. Implement GetRoot interface for proper root object initialization with correct path 6. Add proper path management in List operation to ensure objects have correct paths 7. Fix path handling in error cases and improve logging of failures
Contributor
There was a problem hiding this comment.
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
drivers/aliyundrive_open/driver.go:244
- In the Copy function, duplicate removal errors are logged without affecting the overall copy operation. Verify that this behavior is intentional and does not lead to unintended retention of duplicate files.
if err := d.removeDuplicateFiles(ctx, dstDir.GetPath(), srcObj.GetName(), resp.FileID); err != nil {
…icate file removal Updated the Move, Rename, and Copy methods to log warnings instead of errors when duplicate file removal fails, as the primary operations have already completed successfully. This improves the clarity of logs without affecting the functionality.
Contributor
There was a problem hiding this comment.
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
drivers/aliyundrive_open/driver.go:238
- [nitpick] Changing auto_rename from true to false alters the duplicate file handling behavior. Confirm that this change is intentional and covered by appropriate tests.
"auto_rename": false,
drivers/aliyundrive_open/driver.go:274
- [nitpick] Ensure that the object returned from upload implements model.SetPath; otherwise, the file path may remain unset. Consider adding fallback logic or validating the type before setting the path.
if objWithPath, ok := obj.(model.SetPath); ok {
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (3)
drivers/aliyundrive_open/driver.go:187
- Ensure that dstDir.GetPath() never returns an empty string; otherwise, joining an empty base may lead to incorrect paths. Consider defaulting to '/' if an empty path is possible.
srcObj.Path = filepath.Join(dstDir.GetPath(), srcObj.GetName())
drivers/aliyundrive_open/driver.go:222
- [nitpick] Using an empty string and '.' to decide the valid parentPath may lead to inconsistencies. Consider normalizing the parent path with a standard function or defaulting to '/' to ensure reliable path construction.
if parentPath != "" && parentPath != "." {
drivers/aliyundrive_open/driver.go:272
- When uploading, if dstDir.GetPath() is empty the resulting object may end up with an empty path. Explicitly default to '/' or another valid base directory to avoid this potential issue.
if obj != nil && obj.GetPath() == "" {
xhofe
approved these changes
Apr 19, 2025
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.
建议来自 #7962 (comment)
本次提交解决了阿里云盘开放接口驱动中的几个问题:
这些更改确保了在存在重名文件的情况下,文件操作能够正确工作,同时保持数据完整性并防止重复文件在阿里云盘中累积。