Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

Commit 01c6870

Browse files
shiba4lifeclaude
andcommitted
refactor(apple-import): dedupe non-macOS stub bodies via shared helper
Body was byte-identical across the five run_apple_*_import non-macOS stubs β€” only the JobType label differed. Lift the shared body into mark_apple_import_unavailable_on_non_macos and have each stub make a single one-line call. Behavior preserved: same JobType per kind, same failure message, same mark_failed β†’ mark_terminal β†’ tracker.save ordering. macOS code paths untouched. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f4a9963 commit 01c6870

1 file changed

Lines changed: 21 additions & 20 deletions

File tree

β€Žsrc/server/routes/apple_import.rsβ€Ž

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,22 @@ fn mark_failed(job: &mut Job, msg: String) {
194194
job.message = msg;
195195
}
196196

197+
/// Mark an Apple-import job as unavailable on non-macOS platforms.
198+
///
199+
/// Body shared by every `run_apple_*_import` non-macOS stub β€” the only
200+
/// per-kind variation is the `JobType` label.
201+
#[cfg(not(target_os = "macos"))]
202+
async fn mark_apple_import_unavailable_on_non_macos(
203+
progress_id: String,
204+
tracker: ProgressTracker,
205+
job_kind: &'static str,
206+
) {
207+
let mut job = Job::new(progress_id, JobType::Other(job_kind.into()));
208+
mark_failed(&mut job, "Apple import is only available on macOS".into());
209+
mark_terminal(&mut job);
210+
let _ = tracker.save(&job).await;
211+
}
212+
197213
/// Spawn `work` on the runtime under the caller's user context and return the
198214
/// standard `202 Accepted { success, progress_id }` response that every Apple
199215
/// import handler emits.
@@ -646,10 +662,7 @@ async fn run_apple_notes_import(
646662
_node_arc: std::sync::Arc<crate::fold_node::FoldNode>,
647663
_service: std::sync::Arc<crate::ingestion::ingestion_service::IngestionService>,
648664
) {
649-
let mut job = Job::new(progress_id, JobType::Other("apple-notes".into()));
650-
mark_failed(&mut job, "Apple import is only available on macOS".into());
651-
mark_terminal(&mut job);
652-
let _ = tracker.save(&job).await;
665+
mark_apple_import_unavailable_on_non_macos(progress_id, tracker, "apple-notes").await;
653666
}
654667

655668
#[derive(Deserialize, Default)]
@@ -747,10 +760,7 @@ async fn run_apple_reminders_import(
747760
_node_arc: std::sync::Arc<crate::fold_node::FoldNode>,
748761
_service: std::sync::Arc<crate::ingestion::ingestion_service::IngestionService>,
749762
) {
750-
let mut job = Job::new(progress_id, JobType::Other("apple-reminders".into()));
751-
mark_failed(&mut job, "Apple import is only available on macOS".into());
752-
mark_terminal(&mut job);
753-
let _ = tracker.save(&job).await;
763+
mark_apple_import_unavailable_on_non_macos(progress_id, tracker, "apple-reminders").await;
754764
}
755765

756766
#[derive(Deserialize, Default)]
@@ -1024,10 +1034,7 @@ async fn run_apple_photos_import(
10241034
_service: std::sync::Arc<crate::ingestion::ingestion_service::IngestionService>,
10251035
_upload_storage: fold_db::storage::UploadStorage,
10261036
) {
1027-
let mut job = Job::new(progress_id, JobType::Other("apple-photos".into()));
1028-
mark_failed(&mut job, "Apple import is only available on macOS".into());
1029-
mark_terminal(&mut job);
1030-
let _ = tracker.save(&job).await;
1037+
mark_apple_import_unavailable_on_non_macos(progress_id, tracker, "apple-photos").await;
10311038
}
10321039

10331040
#[derive(Deserialize, Default)]
@@ -1100,10 +1107,7 @@ async fn run_apple_calendar_import(
11001107
_node_arc: std::sync::Arc<crate::fold_node::FoldNode>,
11011108
_service: std::sync::Arc<crate::ingestion::ingestion_service::IngestionService>,
11021109
) {
1103-
let mut job = Job::new(progress_id, JobType::Other("apple-calendar".into()));
1104-
mark_failed(&mut job, "Apple import is only available on macOS".into());
1105-
mark_terminal(&mut job);
1106-
let _ = tracker.save(&job).await;
1110+
mark_apple_import_unavailable_on_non_macos(progress_id, tracker, "apple-calendar").await;
11071111
}
11081112

11091113
#[derive(Deserialize, Default)]
@@ -1170,10 +1174,7 @@ async fn run_apple_contacts_import(
11701174
_node_arc: std::sync::Arc<crate::fold_node::FoldNode>,
11711175
_service: std::sync::Arc<crate::ingestion::ingestion_service::IngestionService>,
11721176
) {
1173-
let mut job = Job::new(progress_id, JobType::Other("apple-contacts".into()));
1174-
mark_failed(&mut job, "Apple import is only available on macOS".into());
1175-
mark_terminal(&mut job);
1176-
let _ = tracker.save(&job).await;
1177+
mark_apple_import_unavailable_on_non_macos(progress_id, tracker, "apple-contacts").await;
11771178
}
11781179

11791180
// ── Auto-Sync Config Routes ─────────────────────────────────────────

0 commit comments

Comments
Β (0)