Skip to content

feat(sync): Sync pipeline — OneDrive download, upload, conflict handling #27

@jaybarden1

Description

@jaybarden1

Summary

Implement the full OneDrive sync pipeline as described in .claude/rules/onedrive-sync.md. This covers the six ordered pipeline steps, parallel job execution, conflict detection/resolution, and the background scheduler.

Depends on

Scope

Pipeline steps (in order)

  1. RemoteFolderEnumerator — fetch DeltaItem list from selected remote folders
  2. RemoteDeletionDetector — delete local files whose remote counterpart is gone
  3. LocalDeletionDetector — delete remote files the user deleted locally
  4. DownloadJobBuilder — build download jobs (eTag-then-timestamp decision logic)
  5. LocalChangeDetector — build upload jobs for new/changed local files
  6. JobExecutorISyncPipeline → parallel workers via bounded Channel<SyncJob>

Key services

Interface Notes
ISyncService SyncAccountAsync, ResolveConflictAsync, events
ISyncScheduler System.Threading.Timer, 60 min default, re-entrancy guard
ISyncPipeline Bounded channel, workerCount from account.SyncConfig.WorkerCount
ISyncWorker / ISyncWorkerFactory Per-worker execution
IHttpDownloader Pre-signed URL download with retry/backoff
IUploadService Resumable upload sessions, 10 MB chunks, retry/backoff
ISyncedItemRegistrar Folder registration during enumeration
SyncRuleEvaluator Most-specific-wins, default-deny
FileClassifier Keyword tokenisation against FileClassificationRule
ConflictResolver / ConflictApplier ConflictPolicy enum: KeepLocal / KeepRemote / Skip

Events

  • ISyncService.SyncProgressChanged (SyncProgressEventArgs)
  • ISyncService.JobCompleted (JobCompletedEventArgs)
  • ISyncService.ConflictDetected (SyncConflict)
  • ISyncScheduler.SyncStarted / SyncCompleted

ViewModels subscribe to these events and marshal to UI thread via RxApp.MainThreadScheduler.

Error types

  • SyncError discriminated union: SyncAuthError, SyncGraphError, SyncStorageError, NoFoldersConfiguredError, SyncCancelledError

File system

All file I/O via IFileSystem (Testably abstraction). System.IO.* banned.

Acceptance criteria

  • Sync runs for an OneDrive account and downloads new/changed files.
  • Upload detects locally changed files and pushes them to OneDrive.
  • Conflicts detected and surfaced via ConflictDetected event.
  • Background scheduler fires every 60 minutes; manual trigger works.
  • Re-entrancy guard prevents overlapping sync passes.
  • Per-account cancellation works.
  • Upload uses resumable sessions with 10 MB chunks and retry backoff.
  • Download honours eTag-then-timestamp decision logic.
  • dotnet build zero warnings; dotnet test all pass (unit + integration).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions