From c00a1fbafa07012e482e4aebb15cff9a315902c3 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Fri, 7 Feb 2025 13:59:21 -0500 Subject: [PATCH] Revert "edit prediction: Fix license detection error logging + check for different spellings (#24281)" This reverts commit 9f825ca3cfd15a84f4aaae3a4153f650d1a991fa. --- crates/zeta/src/zeta.rs | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/crates/zeta/src/zeta.rs b/crates/zeta/src/zeta.rs index a57ce96092e5178abbfc95894b2e77b63a5c89f7..9f69af648f32a36098d44fc5fd60377eefa68936 100644 --- a/crates/zeta/src/zeta.rs +++ b/crates/zeta/src/zeta.rs @@ -952,33 +952,21 @@ impl LicenseDetectionWatcher { pub fn new(worktree: &Worktree, cx: &mut Context) -> Self { let (mut is_open_source_tx, is_open_source_rx) = watch::channel_with::(false); - const LICENSE_FILES_TO_CHECK: [&'static str; 2] = ["LICENSE", "LICENCE"]; // US and UK English spelling - - // Check if worktree is a single file, if so we do not need to check for a LICENSE file - let task = if worktree.abs_path().is_file() { - Task::ready(()) - } else { - let loaded_files_task = futures::future::join_all( - LICENSE_FILES_TO_CHECK - .iter() - .map(|file| worktree.load_file(Path::new(file), cx)), - ); - - cx.background_executor().spawn(async move { - for loaded_file in loaded_files_task.await { - if let Some(content) = loaded_file.log_err() { - if is_license_eligible_for_data_collection(&content.text) { - *is_open_source_tx.borrow_mut() = true; - break; - } - } - } - }) - }; + let loaded_file_fut = worktree.load_file(Path::new("LICENSE"), cx); Self { is_open_source_rx, - _is_open_source_task: task, + _is_open_source_task: cx.spawn(|_, _| async move { + // TODO: Don't display error if file not found + let Some(loaded_file) = loaded_file_fut.await.log_err() else { + return; + }; + + let is_loaded_file_open_source_thing: bool = + is_license_eligible_for_data_collection(&loaded_file.text); + + *is_open_source_tx.borrow_mut() = is_loaded_file_open_source_thing; + }), } }