fix leak tasks
This commit is contained in:
@@ -87,7 +87,7 @@ pub struct RepoStore {
|
||||
///
|
||||
/// Avoids re-running the maintainer Auto sync on every refresh.
|
||||
synced_maintainers: HashSet<PublicKey>,
|
||||
/// In-flight refresh tasks.
|
||||
/// In-flight tasks, cancelled when the store drops.
|
||||
tasks: Vec<Task<Result<(), Error>>>,
|
||||
/// Backend subscription of an announced repository. `None` while local-only.
|
||||
_subscription: Option<Subscription>,
|
||||
@@ -770,9 +770,9 @@ impl RepoStore {
|
||||
.collect()
|
||||
};
|
||||
|
||||
cx.spawn(async move |this, cx| {
|
||||
// The PR references the root patch event.
|
||||
// Viewers can then find the patch without carrying it inline.
|
||||
let task: Task<Result<(), Error>> = cx.spawn(async move |this, cx| {
|
||||
// The PR references the root patch,
|
||||
// viewers can then find the patch without carrying it inline.
|
||||
let root_patch = match publish_patch_series(
|
||||
&this,
|
||||
cx,
|
||||
@@ -838,24 +838,17 @@ impl RepoStore {
|
||||
};
|
||||
|
||||
let builder = this.update(cx, |this, _cx| {
|
||||
// NIP-34 PRs carry at least one clone URL.
|
||||
// The tip commit is downloadable from it.
|
||||
// The author's `/prs/` URLs come first.
|
||||
// They are author-controlled and most likely alive.
|
||||
// The announced mirrors follow.
|
||||
// The list is fixed before signing.
|
||||
// The pushed ref name embeds the event id.
|
||||
// Every candidate URL is listed up front.
|
||||
// Dead URLs are inert, the linked patch stays the source of truth.
|
||||
let prs_urls: Vec<Url> = author_targets
|
||||
.iter()
|
||||
.filter_map(|(url, _)| Url::parse(url).ok())
|
||||
.collect();
|
||||
|
||||
let base_clone = this
|
||||
.announcement
|
||||
.as_ref()
|
||||
.map(|a| a.clone.clone())
|
||||
.unwrap_or_default();
|
||||
|
||||
let clone = pr_clone_urls(prs_urls, base_clone);
|
||||
|
||||
let builder = GitPullRequest {
|
||||
@@ -880,8 +873,6 @@ impl RepoStore {
|
||||
})?;
|
||||
|
||||
// Sign before publishing.
|
||||
// The tip is pushed to the grasp servers under `refs/nostr/<event-id>`.
|
||||
// Nak's convention, readers fetch that ref for the commit behind the `c` tag.
|
||||
let event = cx
|
||||
.background_spawn({
|
||||
let signer = signer.clone();
|
||||
@@ -892,20 +883,22 @@ impl RepoStore {
|
||||
if let Some(path) = push_from.as_ref() {
|
||||
let tip = current_commit.to_string();
|
||||
let reference = format!("refs/nostr/{}", event.id.to_hex());
|
||||
|
||||
let (pushed, failures) = cx
|
||||
.background_spawn({
|
||||
let path = path.clone();
|
||||
let tip = tip.clone();
|
||||
let reference = reference.clone();
|
||||
// Author servers first, then the announced base grasp servers.
|
||||
// The extra targets are best-effort redundancy.
|
||||
let targets: Vec<(String, String)> = author_targets
|
||||
.into_iter()
|
||||
.chain(base_targets)
|
||||
.collect();
|
||||
|
||||
async move {
|
||||
let mut failures = Vec::new();
|
||||
let mut pushed = 0;
|
||||
|
||||
for (url, label) in &targets {
|
||||
match signed_git::push_commit_ref(
|
||||
&path, url, &tip, &reference,
|
||||
@@ -914,6 +907,7 @@ impl RepoStore {
|
||||
Err(e) => failures.push(format!("{label}: {e}")),
|
||||
}
|
||||
}
|
||||
|
||||
(pushed, failures)
|
||||
}
|
||||
})
|
||||
@@ -957,8 +951,8 @@ impl RepoStore {
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.detach();
|
||||
});
|
||||
self.tasks.push(task);
|
||||
}
|
||||
|
||||
/// Generate the patch between `merge_base` and `compare_ref` in `repo_path`,
|
||||
@@ -1086,7 +1080,7 @@ impl RepoStore {
|
||||
.map(|a| a.clone.clone())
|
||||
.unwrap_or_default();
|
||||
|
||||
cx.spawn(async move |this, cx| {
|
||||
let task: Task<Result<(), Error>> = cx.spawn(async move |this, cx| {
|
||||
if let Err(e) = publish_patch_series(
|
||||
&this,
|
||||
cx,
|
||||
@@ -1145,8 +1139,8 @@ impl RepoStore {
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.detach();
|
||||
});
|
||||
self.tasks.push(task);
|
||||
}
|
||||
|
||||
/// Set the status of a root event.
|
||||
@@ -1272,7 +1266,7 @@ impl RepoStore {
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
task.detach();
|
||||
self.tasks.push(task);
|
||||
}
|
||||
|
||||
/// The latest announcement of this repository,
|
||||
@@ -1588,7 +1582,7 @@ impl RepoStore {
|
||||
|
||||
Ok(())
|
||||
});
|
||||
task.detach();
|
||||
self.tasks.push(task);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -303,6 +303,7 @@ pub struct CommitDiffView {
|
||||
loading: bool,
|
||||
error: Option<SharedString>,
|
||||
pane: Entity<DiffPane>,
|
||||
tasks: Vec<gpui::Task<Result<(), anyhow::Error>>>,
|
||||
}
|
||||
|
||||
impl CommitDiffView {
|
||||
@@ -336,6 +337,7 @@ impl CommitDiffView {
|
||||
loading: true,
|
||||
error: None,
|
||||
pane,
|
||||
tasks: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +385,7 @@ impl CommitDiffView {
|
||||
Ok(())
|
||||
});
|
||||
|
||||
task.detach();
|
||||
self.tasks.push(task);
|
||||
}
|
||||
|
||||
fn render_header(&self, cx: &mut Context<Self>) -> AnyElement {
|
||||
|
||||
@@ -79,8 +79,7 @@ pub struct PullRequestDetailView {
|
||||
pane: Entity<DiffPane>,
|
||||
commit_item_sizes: Rc<Vec<Size<Pixels>>>,
|
||||
commit_scroll_handle: VirtualListScrollHandle,
|
||||
/// The dock caches item panels, so without this observer a panel opened
|
||||
/// before the store loaded would stay on its placeholder.
|
||||
tasks: Vec<gpui::Task<Result<(), anyhow::Error>>>,
|
||||
_subscription: Subscription,
|
||||
}
|
||||
|
||||
@@ -124,6 +123,7 @@ impl PullRequestDetailView {
|
||||
pane,
|
||||
commit_item_sizes: Rc::new(Vec::new()),
|
||||
commit_scroll_handle: VirtualListScrollHandle::new(),
|
||||
tasks: Vec::new(),
|
||||
_subscription: subscription,
|
||||
}
|
||||
}
|
||||
@@ -327,7 +327,7 @@ impl PullRequestDetailView {
|
||||
Ok(())
|
||||
});
|
||||
|
||||
task.detach();
|
||||
self.tasks.push(task);
|
||||
}
|
||||
|
||||
/// Open the diff of `commit_id` in the bottom dock of the area.
|
||||
|
||||
@@ -68,6 +68,7 @@ pub struct NewPullRequestView {
|
||||
pane: Entity<DiffPane>,
|
||||
scroll_handle: VirtualListScrollHandle,
|
||||
item_sizes: Rc<Vec<Size<Pixels>>>,
|
||||
tasks: Vec<gpui::Task<Result<(), anyhow::Error>>>,
|
||||
_subscriptions: Vec<Subscription>,
|
||||
}
|
||||
|
||||
@@ -323,6 +324,7 @@ impl NewPullRequestView {
|
||||
pane,
|
||||
scroll_handle: VirtualListScrollHandle::new(),
|
||||
item_sizes: Rc::new(Vec::new()),
|
||||
tasks: Vec::new(),
|
||||
_subscriptions: subscriptions,
|
||||
}
|
||||
}
|
||||
@@ -390,7 +392,8 @@ impl NewPullRequestView {
|
||||
|
||||
Ok(())
|
||||
});
|
||||
task.detach();
|
||||
|
||||
self.tasks.push(task);
|
||||
}
|
||||
|
||||
/// Branches and the current branch are read off the UI thread, then applied.
|
||||
@@ -419,7 +422,8 @@ impl NewPullRequestView {
|
||||
|
||||
Ok(())
|
||||
});
|
||||
task.detach();
|
||||
|
||||
self.tasks.push(task);
|
||||
}
|
||||
|
||||
fn apply_checkout(
|
||||
@@ -636,7 +640,8 @@ impl NewPullRequestView {
|
||||
|
||||
Ok(())
|
||||
});
|
||||
task.detach();
|
||||
|
||||
self.tasks.push(task);
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
@@ -830,7 +835,7 @@ impl NewPullRequestView {
|
||||
Ok(())
|
||||
});
|
||||
|
||||
task.detach();
|
||||
self.tasks.push(task);
|
||||
}
|
||||
|
||||
fn submit(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
@@ -911,7 +916,7 @@ impl NewPullRequestView {
|
||||
Ok(())
|
||||
});
|
||||
|
||||
task.detach();
|
||||
self.tasks.push(task);
|
||||
}
|
||||
|
||||
fn open_commit_diff(&mut self, commit_id: &str, window: &mut Window, cx: &mut Context<Self>) {
|
||||
|
||||
Reference in New Issue
Block a user