get compile

This commit is contained in:
dignifiedquire
2023-07-14 16:29:31 +02:00
parent 6f35e52fd9
commit db8c3352ee
3 changed files with 16 additions and 19 deletions

1
Cargo.lock generated
View File

@@ -1242,6 +1242,7 @@ dependencies = [
"humansize", "humansize",
"image", "image",
"iroh", "iroh",
"iroh-io",
"kamadak-exif", "kamadak-exif",
"lettre_email", "lettre_email",
"libc", "libc",

View File

@@ -51,6 +51,7 @@ hex = "0.4.0"
humansize = "2" humansize = "2"
image = { version = "0.24.6", default-features=false, features = ["gif", "jpeg", "ico", "png", "pnm", "webp", "bmp"] } image = { version = "0.24.6", default-features=false, features = ["gif", "jpeg", "ico", "png", "pnm", "webp", "bmp"] }
iroh = { version = "0.4.1", default-features = false, git = "https://github.com/n0-computer/iroh", branch = "main", features = ["iroh-collection", "flat-db"] } iroh = { version = "0.4.1", default-features = false, git = "https://github.com/n0-computer/iroh", branch = "main", features = ["iroh-collection", "flat-db"] }
iroh-io = "0.2.1"
kamadak-exif = "0.5" kamadak-exif = "0.5"
lettre_email = { git = "https://github.com/deltachat/lettre", branch = "master" } lettre_email = { git = "https://github.com/deltachat/lettre", branch = "master" }
libc = "0.2" libc = "0.2"

View File

@@ -46,10 +46,12 @@ use iroh::net::defaults::default_derp_map;
use iroh::net::tls::Keypair; use iroh::net::tls::Keypair;
use iroh::node::{Event, Node as IrohNode, StaticTokenAuthHandler}; use iroh::node::{Event, Node as IrohNode, StaticTokenAuthHandler};
use iroh::util::progress::ProgressEmitter; use iroh::util::progress::ProgressEmitter;
use tokio::fs::{self, File}; use iroh_io::AsyncSliceWriter;
use tokio::io::AsyncWriteExt; use tokio::fs;
use tokio::sync::broadcast::error::RecvError; use tokio::sync::{
use tokio::sync::{broadcast, Mutex}; broadcast::{self, error::RecvError},
Mutex,
};
use tokio::task::{JoinHandle, JoinSet}; use tokio::task::{JoinHandle, JoinSet};
use tokio_stream::wrappers::ReadDirStream; use tokio_stream::wrappers::ReadDirStream;
use tokio_util::sync::CancellationToken; use tokio_util::sync::CancellationToken;
@@ -64,8 +66,6 @@ use crate::{e2ee, EventType};
use super::{export_database, DBFILE_BACKUP_NAME}; use super::{export_database, DBFILE_BACKUP_NAME};
const MAX_CONCURRENT_DIALS: u8 = 16;
type Node = IrohNode<iroh::database::flat::Database>; type Node = IrohNode<iroh::database::flat::Database>;
/// Provide or send a backup of this device. /// Provide or send a backup of this device.
@@ -506,7 +506,7 @@ async fn run_get_request(
context.emit_event(ReceiveProgress::Connected.into()); context.emit_event(ReceiveProgress::Connected.into());
// we assume that the request includes the entire collection // we assume that the request includes the entire collection
let (mut next, root, collection) = { let (mut next, _root, collection) = {
let ConnectedNext::StartRoot(sc) = connected.next().await? else { let ConnectedNext::StartRoot(sc) = connected.next().await? else {
bail!("request did not include collection"); bail!("request did not include collection");
}; };
@@ -522,24 +522,21 @@ async fn run_get_request(
}; };
// download all the children // download all the children
let mut current_blob = 0; let mut blobs = collection.blobs().iter();
let finishing = loop { let finishing = loop {
let start = match next { let start = match next {
EndBlobNext::MoreChildren(start) => start, EndBlobNext::MoreChildren(start) => start,
EndBlobNext::Closing(finishing) => break finishing, EndBlobNext::Closing(finishing) => break finishing,
}; };
let child_offset = start.child_offset();
let offset = child_offset + 1;
// get the hash of the next blob, or finish if there are no more // get the hash of the next blob, or finish if there are no more
let Some(blob) = collection.blobs().get(current_blob) else { let Some(blob) = blobs.next() else {
break start.finish(); break start.finish();
}; };
let start = start.next(blob.hash); let start = start.next(blob.hash);
let done = on_blob(context, progress, jobs, &ticket, start, &blob.name).await?; let done = on_blob(context, jobs, &ticket, start, &blob.name).await?;
current_blob += 1;
next = done.next(); next = done.next();
}; };
let stats = finishing.next().await?; let stats = finishing.next().await?;
@@ -553,10 +550,9 @@ async fn run_get_request(
/// the database of the current [`Context`]. /// the database of the current [`Context`].
async fn on_blob( async fn on_blob(
context: &Context, context: &Context,
progress: &ProgressEmitter,
jobs: &Mutex<JoinSet<()>>, jobs: &Mutex<JoinSet<()>>,
ticket: &Ticket, ticket: &Ticket,
mut state: fsm::AtBlobHeader, state: fsm::AtBlobHeader,
name: &str, name: &str,
) -> Result<fsm::AtEndBlob> { ) -> Result<fsm::AtEndBlob> {
ensure!(!name.is_empty(), "Received a nameless blob"); ensure!(!name.is_empty(), "Received a nameless blob");
@@ -577,13 +573,12 @@ async fn on_blob(
context.get_blobdir().join(blobname) context.get_blobdir().join(blobname)
}; };
let file = File::create(&path).await?; let file_path = path.clone();
// TODO: BufWriter doesn't implement AsyncSliceWriter :( let mut file = iroh_io::File::create(move || std::fs::File::create(&file_path)).await?;
// let mut file = BufWriter::with_capacity(128 * 1024, file);
// TODO: ProgressEmitter doesn't support writers :( // TODO: ProgressEmitter doesn't support writers :(
// let mut wrapped_file = progress.wrap_async_write(&mut file); // let mut wrapped_file = progress.wrap_async_write(&mut file);
let done = state.write_all(&mut file).await?; let done = state.write_all(&mut file).await?;
file.flush().await?; file.sync().await?;
if name.starts_with("db/") { if name.starts_with("db/") {
let context = context.clone(); let context = context.clone();