From 3937878f219451784f674cb8eacae1db53bf5634 Mon Sep 17 00:00:00 2001 From: Luisa Vasquez Gomez Date: Wed, 11 Dec 2024 04:57:17 -0800 Subject: [PATCH] modern sync: add upload_trees method Summary: Unused for now, this is prep for sending hg data Reviewed By: andreacampi Differential Revision: D67006514 fbshipit-source-id: a554ca3523aff387f8e88e6fe7d32a4970870b3e --- eden/mononoke/modern_sync/src/sender.rs | 4 ++++ eden/mononoke/modern_sync/src/sender/dummy.rs | 8 ++++++++ eden/mononoke/modern_sync/src/sender/edenapi.rs | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/eden/mononoke/modern_sync/src/sender.rs b/eden/mononoke/modern_sync/src/sender.rs index 1817f7d30eaff..837ee67dab54b 100644 --- a/eden/mononoke/modern_sync/src/sender.rs +++ b/eden/mononoke/modern_sync/src/sender.rs @@ -7,6 +7,7 @@ use anyhow::Result; use async_trait::async_trait; +use edenapi_types::UploadTreeEntry; use mononoke_types::ContentId; use mononoke_types::FileContents; pub mod dummy; @@ -15,4 +16,7 @@ pub mod edenapi; #[async_trait] pub trait ModernSyncSender { async fn upload_content(&self, content_id: ContentId, _blob: FileContents) -> Result<()>; + + #[allow(unused)] + async fn upload_tree(&self, trees: Vec) -> Result<()>; } diff --git a/eden/mononoke/modern_sync/src/sender/dummy.rs b/eden/mononoke/modern_sync/src/sender/dummy.rs index aa06532ffc891..49fe678e37680 100644 --- a/eden/mononoke/modern_sync/src/sender/dummy.rs +++ b/eden/mononoke/modern_sync/src/sender/dummy.rs @@ -7,6 +7,7 @@ use anyhow::Result; use async_trait::async_trait; +use edenapi_types::UploadTreeEntry; use mononoke_types::ContentId; use mononoke_types::FileContents; use slog::info; @@ -31,4 +32,11 @@ impl ModernSyncSender for DummySender { info!(&self.logger, "Uploading content with id: {:?}", content_id); Ok(()) } + + async fn upload_tree(&self, trees: Vec) -> Result<()> { + for tree in trees { + info!(&self.logger, "Uploading tree with id {:?}", tree.node_id); + } + Ok(()) + } } diff --git a/eden/mononoke/modern_sync/src/sender/edenapi.rs b/eden/mononoke/modern_sync/src/sender/edenapi.rs index cba85cbc7e9cf..081cc66cdd25a 100644 --- a/eden/mononoke/modern_sync/src/sender/edenapi.rs +++ b/eden/mononoke/modern_sync/src/sender/edenapi.rs @@ -16,6 +16,7 @@ use edenapi::HttpClientBuilder; use edenapi::HttpClientConfig; use edenapi::SaplingRemoteApi; use edenapi_types::AnyFileContentId; +use edenapi_types::UploadTreeEntry; use futures::TryStreamExt; use mononoke_app::args::TLSArgs; use mononoke_types::FileContents; @@ -99,4 +100,14 @@ impl ModernSyncSender for EdenapiSender { Ok(()) } + + async fn upload_tree(&self, trees: Vec) -> Result<()> { + let res = self.client.upload_trees_batch(trees).await?; + info!( + &self.logger, + "Upload tree response: {:?}", + res.entries.try_collect::>().await? + ); + Ok(()) + } }