No description
Find a file
Winarto Zhao 63ce81fa40 feat: Add intelligent two-way iCloud sync with automatic conflict resolution
Enhanced CacheService with smart sync capabilities that automatically detect
and resolve conflicts by comparing modification timestamps.

Major changes:
- Add smartSync() method for bidirectional sync with automatic direction detection
- Enhanced syncToiCloud() and syncFromiCloud() with detailed logging
- Sync now compares timestamps and only syncs when one side is newer
- Handles all sync scenarios: no data, one-sided data, and conflicting data
- App automatically syncs on launch using smart sync

Sync scenarios handled:
  • No data on either side → No action needed
  • Only local data exists → Auto-upload to iCloud
  • Only iCloud data exists → Auto-download to device
  • Both exist with different timestamps → Sync newer to older
  • Both in sync → No transfer needed

Settings improvements:
- Changed "Sync Now" button to "Smart Sync"
- Added restoreFromiCloud() function for manual force download
- Smart Sync automatically saves settings before syncing
- Better user feedback with detailed console logging

Benefits:
- New device setup automatically downloads iCloud data
- Switching between devices keeps data in sync
- Never overwrites newer data with older data
- Manual restore option available when needed
- Encrypted settings (API keys, tokens) sync securely

Debug features:
- Console logs show sync direction and reason
- File counts displayed after sync
- Timestamp comparisons logged for transparency
2026-01-11 18:12:53 +08:00
Managarr feat: Add intelligent two-way iCloud sync with automatic conflict resolution 2026-01-11 18:12:53 +08:00
Managarr.xcodeproj feat: Add intelligent two-way iCloud sync with automatic conflict resolution 2026-01-11 18:12:53 +08:00
.gitignore Initial commit 2026-01-10 23:08:47 +08:00
CLAUDE.md feat: Add intelligent two-way iCloud sync with automatic conflict resolution 2026-01-11 18:12:53 +08:00
README.md Initial commit 2026-01-10 23:08:47 +08:00

Managarr

An iOS app for managing your Sonarr instance.

Features

  • View all your series in a clean, organized list
  • See detailed information about each series including seasons, episodes, and statistics
  • Browse upcoming episodes in a calendar view
  • Search and add new series to your Sonarr instance
  • Configure multiple Sonarr servers

Requirements

  • iOS 17.0 or later
  • Xcode 15.0 or later
  • A running Sonarr instance (v3 API)

Getting Started

  1. Open Managarr.xcodeproj in Xcode
  2. Select your target device or simulator
  3. Build and run the project
  4. In the Settings tab, configure your Sonarr server:
    • Enter your Sonarr server URL (e.g., http://192.168.1.100:8989)
    • Enter your API key (found in Sonarr: Settings → General → Security → API Key)
    • Tap "Test Connection" to verify the settings

Project Structure

Managarr/
├── ManagearrApp.swift          # App entry point
├── ContentView.swift            # Main tab view
├── Models/
│   ├── Series.swift             # Series data model
│   └── Episode.swift            # Episode data model
├── Services/
│   └── SonarrService.swift      # API client for Sonarr
├── Views/
│   ├── SeriesListView.swift     # List of all series
│   ├── SeriesDetailView.swift   # Detailed series view
│   ├── CalendarView.swift       # Upcoming episodes
│   ├── SettingsView.swift       # App settings
│   └── AddSeriesView.swift      # Search and add series
├── Assets.xcassets/             # App assets and icons
└── Info.plist                   # App configuration

API Integration

This app uses the Sonarr v3 API. The following endpoints are implemented:

  • GET /api/v3/series - Fetch all series
  • GET /api/v3/calendar - Fetch upcoming episodes
  • GET /api/v3/series/lookup - Search for series

Configuration

The app stores your Sonarr server configuration in UserDefaults:

  • sonarr_url: Your Sonarr server URL
  • sonarr_api_key: Your Sonarr API key

Security

  • API keys are stored securely in UserDefaults
  • The app allows arbitrary loads in NSAppTransportSecurity to support HTTP connections to local Sonarr instances
  • For production use, consider using HTTPS and the iOS Keychain for API key storage

Future Enhancements

  • Support for multiple Sonarr instances
  • Episode file management
  • Quality profile management
  • Series monitoring controls
  • Push notifications for new episodes
  • Search for missing episodes
  • Series statistics and charts

License

This project is provided as-is for personal use.