Skip to content

iclouddrive: add icloud photos support - #8734

Closed
coughlanio wants to merge 1 commit into
rclone:masterfrom
coughlanio:icloudphotos
Closed

coughlanio wants to merge 1 commit into
rclone:masterfrom
coughlanio:icloudphotos

Conversation

@coughlanio

@coughlanio coughlanio commented Aug 6, 2025 •

Copy link
Copy Markdown
Contributor

What is the purpose of this change?

This PR adds iCloud Photos support to the existing iclouddrive backend, creating a unified iCloud backend that allows users to access both iCloud Drive and iCloud Photos through a single backend with service selection.

Key changes:

  • Unified Backend: Users can now select "Drive" or "Photos" when configuring the iclouddrive backend, eliminating the need for a separate icloudphotos backend
  • Shared Authentication: Both services use the same authentication flow and session management, reducing code duplication
  • Photos Functionality: Full read-only access to iCloud Photos including:
    • Library and album listing with accurate file counts
    • Smart albums support (All Photos, Videos, Favorites, etc.)
    • Photo and video downloading with range request support
    • Proper metadata handling (file sizes, modification times)
  • Clean Architecture: Router-based design that delegates to service-specific implementations while maintaining separation of concerns
  • Backward Compatibility: Existing iclouddrive configurations continue to work unchanged (defaults to Drive service)

Technical Implementation:

  • Added service configuration option to select between "drive" and "photos"
  • Created icloud.go as the main router handling authentication and service routing
  • Added Photos implementation to icloudphotos.go within the iclouddrive package
  • Shared API client code between Drive and Photos (api/client.go, api/session.go)

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

#7982

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 :-)

@coughlanio

Copy link
Copy Markdown
Contributor Author

Recent updates since yesterday:

Architecture improvements:

  • Integrated the code into the existing iclouddrive backend with a new configuration option to toggle between iCloud Drive and iCloud Photos modes during setup. This approach aligns with previous discussions in the project—though we might want to consider renaming the backend to simply icloud at some point.
  • Added DirCache functionality for better performance.

API challenges (the joys of undocumented APIs!):

  • Running into some inconsistent behavior—I can successfully retrieve user albums but can't fetch photos from within those albums. Shared albums also aren't appearing as expected.
  • Discovered a sync issue where the reported photo count doesn't match what actually downloads. For example, my "All Photos" album shows 2,686 photos via API call, but only ~2,512 actually sync (interestingly, my iPhone's Photos app shows 2,685). The discrepancy seems related to duplicate detection:
    2025/08/06 22:27:21 NOTICE: All Photos/IMG_3731.HEIC: Duplicate object found in source - ignoring
    This duplicate handling behavior could be problematic and needs a workaround.

I'm continuing to test and refine these issues.

@voltagex

voltagex commented Oct 4, 2025

Copy link
Copy Markdown

I don't know if this helps but I have noticed some of the same duplication if you request your photos via data and privacy from Apple

@fschoenfeldt

Copy link
Copy Markdown

@coughlanio

Thanks for your work! 🚀

Out of curiosity: does this add support for also uploading photos and if not, do you plan adding it here?

@ajnart

ajnart commented Dec 15, 2025 •

Copy link
Copy Markdown

@coughlanio just out of curiosity, you left the last todo list item unticked :

[ ] I'm done, this Pull Request is ready for review :-)

Does that mean you are still working on this PR ? I would love to see it reviewed and potentially added

@coughlanio

Copy link
Copy Markdown
Contributor Author

@ajnart I've been short on time so I've not made any progress - current state of this is very much a functional POC with some rough edges - if someone wants to take a look, be my guest!

@JoshPaterson

Copy link
Copy Markdown

@Lyapsus: you mentioned wanting me to look at this in #9209, are you looking for help testing this branch?

@Lyapsus

Lyapsus commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

@JoshPaterson damn sorry, wrong id - I meant #9234

@ncw ncw closed this in d0c469c Apr 27, 2026
ferferga pushed a commit to ferferga/rclone that referenced this pull request Oct 6, 2026
Add read-only iCloud Photos support to the existing iclouddrive
backend via `service = photos` config option.

Also includes auth improvements on top of rclone#9209's SRP authentication.

**Photos features:**
- 3-level hierarchy: libraries (Personal + Shared Photo Library) →
  albums → photos/videos
- server-side smart albums (All Photos, Videos, Favorites,
  Screenshots, Live, Bursts, Panoramas, Slo-mo, Time-lapse, Portrait,
  Long Exposure, Animated, Hidden, Recently Deleted)
- User-created albums and nested album folders
- Live Photo `.MOV` companions as first-class entries
- Edited photo versions (`-edited` suffix) and RAW alternatives
- Duplicate filename dedup for camera counter wrap collisions
- Parallel cold listing for large albums
- Delta sync via CloudKit `changes/zone` - warm listings near-instant from disk cache
- Disk cache (libraries, albums, photos) with atomic writes for crash safety
- `ChangeNotify` support for FUSE mounts via `changes/zone` polling
- `ListR` support for `--fast-list` and recursive operations
- `--metadata` support - width, height, added-time, favorite, hidden
- Fresh download URLs per file - no stale URL failures on long copies
- FUSE mount documentation with recommended flags

**Auth improvements over rclone#9209:**
- SMS 2FA fallback for users without trusted Apple devices
- Explicit push notification request - fixes iOS/macOS 26.4+ where 409
  no longer auto-pushes
- Thread safety for concurrent FUSE callers (mutexes on session and client state)
- Session endpoint caching - skips ~5s `/validate` round-trip on warm start
- `Disconnect` support - clears auth state + disk cache
- PCS cookie support for Advanced Data Protection accounts, including
  trusted-device approval for PCS cookies

Built on @coughlanio's Photos PoC (Closes rclone#8734) and @mikegillan's SRP auth (rclone#9209).

Fixes rclone#7982
Co-authored-by: Chris Coughlan <[email protected]>
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.

6 participants