Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sanchuanhehe
Copy link

@sanchuanhehe sanchuanhehe commented Oct 8, 2025

What is the purpose of this change?

This PR adds support for Huawei Drive (华为云盘) as a new backend for rclone. Huawei Drive is a cloud storage service provided by Huawei, primarily used in China.

Key features implemented:

  • Full OAuth2 authentication with Huawei Drive API v1
  • File upload with intelligent size-based strategy:
    • Small files (< 20MB): multipart upload
    • Large files (≥ 20MB): resumable upload with chunking
  • Complete file operations: upload, download, copy, move, delete
  • Directory operations: create, list, remove
  • Server-side copy support for efficient file operations
  • Proper error handling and retry mechanisms
  • SHA256 hash support for data integrity verification
  • Support for files up to 50GB

Technical implementation:

  • Uses Huawei Drive REST API v1 with proper authentication
  • Implements both multipart and resumable upload protocols
  • Includes comprehensive test suite for all functionality
  • Follows rclone backend conventions and interfaces

Was the change discussed in an issue or in the forum before?

This is a new backend implementation to support users who need to integrate Huawei Drive with rclone for backup, sync, and file management operations.

Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

Files Added/Modified

backend/huaweidrive/
├── api/
│   └── types.go          # API data structures
├── huaweidrive.go        # Main backend implementation
└── huaweidrive_test.go   # Unit tests

# Test files (not included in PR)
├── test_huaweidrive.sh      # Comprehensive test suite
├── quick_test_huaweidrive.sh # Quick functionality test
└── TEST_README.md           # Testing documentation

Testing

The backend has been thoroughly tested with:

  • ✅ Small file uploads (< 1MB)
  • ✅ Medium file uploads (5-20MB) using multipart upload
  • ✅ Large file uploads (20MB+) using resumable upload
  • ✅ File downloads and content verification
  • ✅ Directory operations
  • ✅ Server-side copy operations
  • ✅ File synchronization
  • ✅ Error handling and edge cases
  • ✅ Chinese filename support
  • ✅ Performance testing (up to 50MB files)

Configuration Example

[huaweidrive]
type = huaweidrive
client_id = your_client_id
client_secret = your_client_secret

Performance

  • Upload speed: ~3-4 MB/s (tested with 50MB files)
  • Download speed: ~7-10 MB/s
  • Supports files up to 50GB
  • Efficient chunked upload for large files

Note for reviewers:

  • The implementation follows rclone's backend interface standards
  • All error codes and retry logic are properly implemented
  • OAuth2 flow is tested and working correctly
  • The code includes comprehensive error handling for network issues and API limitations

- Introduced the Huawei Drive backend in rclone, including API types and main functionality.
- Implemented OAuth2 authentication for user credentials.
- Added methods for file and directory operations, including upload, download, and metadata management.
- Created integration tests for the Huawei Drive backend to ensure functionality.
- Added unit tests for core methods such as NewFs, Name, Root, String, Precision, and Hashes.
…ons and clarify application access requirements
…ime support, and add comprehensive testing script

- Updated precision method to indicate that modification times are not supported by Huawei Drive API.
- Adjusted object creation to store modification time and size.
- Modified SetModTime method to return an error indicating that modification times cannot be set.
- Added tests for modification time support and time formatting.
- Introduced a comprehensive bash script for testing various functionalities of the Huawei Drive integration, including connection tests, file operations, and performance evaluations.
…oid network calls and improve move operations
@sanchuanhehe
Copy link
Author

image image Passed basic testing

@sanchuanhehe
Copy link
Author

All planned implementation work has been completed, including authentication, file operations, and comprehensive testing. 
The Huawei Drive backend is stable and has passed all basic functionality tests. 

This pull request is now ready for final review and merge. 
Thank you very much for your time and assistance!  @ncw

- Remove unused `getRootDirectoryID` function.
- Introduce `QueryFilter` struct for building query conditions.
- Enhance `listDirectory` to support additional filters.
- Implement `CleanUp` method to empty the recycle bin.
- Add `validateFileName` function to enforce filename restrictions.
- Update error handling in `shouldRetry` to manage specific error codes.
- Improve tests for filename validation, query filters, and error handling.
- Ensure proper implementation of interfaces and method signatures.
@sanchuanhehe
Copy link
Author

@roucc
Copy link
Member

roucc commented Oct 14, 2025

https://github.com/rclone/rclone/blob/231083647ef96fc97fd4dff6b88b93450a677693/CONTRIBUTING.md#integration-tests

Can you show the results of the test_all integration test as in the link above? Thanks.

@sanchuanhehe
Copy link
Author

image Most of the integration tests have passed successfully. I will continue working on fixing the remaining parts. Thank you for your review and feedback!

@roucc
Copy link
Member

roucc commented Oct 15, 2025

Thanks, doing great, let us know if you want any help or need us to take a look!

@Baneeishaque

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants