Skip to main content

tuwunel_admin/query/storage/
differences.rs

1use std::collections::HashSet;
2
3use futures::{TryStreamExt, future::try_join};
4use tuwunel_core::{Result, utils::stream::IterStream};
5
6use crate::admin_command;
7
8#[admin_command]
9pub(super) async fn query_storage_differences(
10	&self,
11	provider_a: String,
12	provider_b: String,
13) -> Result {
14	let a = self
15		.services
16		.storage
17		.provider(&provider_a)?
18		.list(None)
19		.map_ok(|meta| meta.location)
20		.try_collect::<HashSet<_>>();
21
22	let b = self
23		.services
24		.storage
25		.provider(&provider_b)?
26		.list(None)
27		.map_ok(|meta| meta.location)
28		.try_collect::<HashSet<_>>();
29
30	let (a, b) = try_join(a, b).await?;
31	a.difference(&b)
32		.try_stream()
33		.try_for_each(|item| writeln!(&self, "{item}"))
34		.await
35}