mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-25 01:13:39 +10:00
Use updated droplet-rs
(currently only local installation of droplet supported)
This commit is contained in:
+13
-3
@@ -1,9 +1,12 @@
|
||||
use std::{collections::HashMap, path::Path};
|
||||
|
||||
use droplet_rs::manifest::{Manifest, generate_manifest_rusty};
|
||||
use droplet_rs::manifest::{
|
||||
Manifest, generate_manifest_rusty, generate_manifest_rusty_v2,
|
||||
};
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::io::AsyncWrite;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct DepotManifest {
|
||||
@@ -37,20 +40,27 @@ impl DepotManifest {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn generate_v2_manifest(dir: &Path) -> anyhow::Result<Manifest> {
|
||||
pub async fn generate_v2_manifest<W, F, CloseF>(dir: &Path, factory: F, closer: CloseF) -> anyhow::Result<Manifest>
|
||||
where
|
||||
W: AsyncWrite + Unpin,
|
||||
F: AsyncFn(String) -> W,
|
||||
CloseF: AsyncFn(W)
|
||||
{
|
||||
let progress_bar = ProgressBar::new(10_000).with_style(
|
||||
ProgressStyle::default_bar()
|
||||
.template("[{elapsed_precise}] [ETA {eta}] {bar} {percent_precise}%")
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
generate_manifest_rusty(
|
||||
generate_manifest_rusty_v2(
|
||||
dir,
|
||||
|progress| {
|
||||
let progress_int = (progress * 100f32).round() as u64;
|
||||
progress_bar.set_position(progress_int);
|
||||
},
|
||||
|log| progress_bar.suspend(|| info!("{}", log)),
|
||||
factory,
|
||||
closer
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user