Skip to content

Conversation

@textrix
Copy link
Contributor

@textrix textrix commented Sep 23, 2025

Backend PR for alist

PR Title

feat: Add pCloud driver support

PR Description

Description

Add pCloud driver support to alist with OAuth2 authentication and comprehensive file management capabilities.

Features

  • ✅ OAuth2 authentication with automatic token refresh
  • ✅ Support for US (api.pcloud.com) and EU (eapi.pcloud.com) regions
  • ✅ File operations: list, download, upload, delete
  • ✅ Folder operations: create, rename, move, delete
  • ✅ Server-side copy and move operations
  • ✅ Storage quota information retrieval
  • ✅ Comprehensive error handling and retry logic
  • ✅ Rate limiting compliance (4xxx/5xxx error handling)

API Endpoints Implemented

  • /listfolder - List folder contents with recursive support
  • /getfilelink - Generate secure download URLs with expiration
  • /uploadfile - Upload files with Content-Length requirement
  • /createfolder - Create new folders
  • /deletefile - Delete individual files
  • /deletefolderrecursive - Delete folders and contents
  • /renamefile - Rename and move files
  • /renamefolder - Rename and move folders
  • /copyfile - Server-side file copying
  • /userinfo - Retrieve storage quota and usage information
  • /oauth2_token - OAuth token refresh

Technical Implementation

  • ID Format Handling: Proper conversion between pCloud ID formats (d123/f456)
  • Region Detection: Automatic hostname selection based on OAuth response
  • Content-Length: Proper handling of pCloud's Content-Length requirement
  • Error Classification: Retry logic for 4xxx (rate limiting) and 5xxx (server) errors
  • Link Caching: Efficient download link management with expiration tracking

Testing Completed

  • Build verification: go build -o alist . successful compilation
  • Server startup: pCloud driver loads successfully with success load storage: [/ppp], driver: [pCloud], order: [0]
  • API integration: Driver appears correctly in API driver list with all configuration fields
  • Configuration validation: All 5 setting fields (refresh_token, hostname, root_folder_id, client_id, client_secret) working
  • OAuth authentication: Token refresh mechanism implemented with regional endpoint support
  • Error handling: 4xxx/5xxx error classification with exponential backoff retry logic
  • File operations: List, Link, Put operations verified through driver interface
  • Folder operations: MakeDir, Move, Rename, Copy, Remove operations implemented
  • API methods: Correct GET for reads, POST for writes following rclone patterns
  • Upload optimization: Direct /uploadfile endpoint with PUT method and Content-Length headers

Configuration Options

  • access_token (required): OAuth2 refresh token from pCloud
  • hostname (select): API region - us or eu
  • root_folder_id (optional): Custom root folder ID (default: empty for root)
  • client_id (optional): Custom OAuth client ID for enterprise users
  • client_secret (optional): Custom OAuth client secret for enterprise users

Related Issues

Resolves requests for pCloud integration support.

Related PRs

Please review this PR together with the corresponding frontend PR: AlistGo/alist-web#292
The frontend PR adds the necessary UI components for configuring the pCloud driver.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • Code follows the project's Go coding standards (gofmt applied, consistent style)
  • Self-review of code completed with rclone implementation comparison
  • Code is properly commented with clear English explanations
  • No new linting warnings introduced (clean build output)
  • Error handling follows project patterns (consistent error propagation)
  • HTTP client usage follows project conventions (resty/v2 usage)
  • No hardcoded credentials or sensitive information (OAuth public client pattern)
  • Proper logging levels used throughout (following alist patterns)
  • All driver interfaces properly implemented (Meta, Reader, Writer)
  • Configuration struct properly tagged with JSON and validation tags
  • rclone-level improvements integrated (retry logic, error classification, API optimization)

- Implement OAuth2 authentication with US/EU region support
- Add file operations (list, upload, download, delete, rename, move, copy)
- Add folder operations (create, rename, move, delete)
- Enhance error handling with pCloud-specific retry logic
- Use correct API methods: GET for reads, POST for writes
- Implement direct upload approach for better performance
- Add exponential backoff for failed requests with 4xxx/5xxx classification
@skysliences skysliences self-requested a review September 30, 2025 06:17
@skysliences skysliences merged commit fe564c4 into AlistGo:main Sep 30, 2025
12 checks passed
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