367UBQ6KNAKUEWG32R4QRJ6H7IE7NAZFOPTC3ZOE4Z6E44RV3ISQC
YS2HLPX6S3FCPI3Q7TVFP3XIZPK4JRKV6PFWRNZHCWWC2P2SDDLQC
VMPAOJS2ZFOLNXALHWSVM5AFENWX6ZUACB45EJV3HXI7DQNAZPHQC
Q45QHPO4HDTEZF2W4UDZSYYQ46BPEIWSW4GJILZR5HTJNLKXJABQC
UDHP4ZVBQZT2VBURB2MDCU2IZDNMCAFSIUKWRBDQ5BWMFKSN2LYQC
SXEYMYF7P4RZMZ46WPL4IZUTSQ2ATBWYZX7QNVMS3SGOYXYOHAGQC
76PCXGML77EZWTRI5E6KHLVRAFTJ2AB5YRN5EKOYNAPKTWY2KCGAC
FBXYP7QM7SG6P2JDJVQPPCRKJE3GVYXNQ5GVV4GRDUNG6Q4ZRDJQC
5HF7C67M4DZMYTCIG32XEQQ662AHQMIHTHUK7TAVSO52XLMFBZPAC
fn extended_data(
self,
channel: thrussh::ChannelId,
ext: u32,
data: &[u8],
session: thrussh::client::Session,
) -> Self::FutureUnit {
if ext == 0 {
self.data(channel, data, session)
} else {
let mut stderr = std::io::stderr();
let result = stderr.write_all(data);
Box::pin(async move {
result?;
Ok((self, session))
})
}
}
RemoteRepo::Http(ref h) => {
for c in changes {
libpijul::changestore::filesystem::push_filename(&mut local, &c);
let url = h.url.clone() + "/" + DOT_DIR;
let change = std::fs::read(&local)?;
let mut to_channel = if let Some(ch) = to_channel {
vec![("to_channel", ch)]
} else {
Vec::new()
};
let c = c.to_base32();
to_channel.push(("apply", &c));
debug!("url {:?} {:?}", url, to_channel);
h.client
.post(&url)
.query(&to_channel)
.body(change)
.send()
.await?;
libpijul::changestore::filesystem::pop_filename(&mut local);
}
Ok(())
}
RemoteRepo::Http(ref h) => h.upload_changes(local, to_channel, changes).await,
}
Ok(())
}
pub async fn upload_changes(
&self,
mut local: PathBuf,
to_channel: Option<&str>,
changes: &[libpijul::Hash],
) -> Result<(), anyhow::Error> {
let progress = ProgressBar::new(changes.len() as u64);
progress.println("Uploading changes");
for c in changes {
libpijul::changestore::filesystem::push_filename(&mut local, &c);
let url = self.url.clone() + "/" + super::DOT_DIR;
let change = std::fs::read(&local)?;
let mut to_channel = if let Some(ch) = to_channel {
vec![("to_channel", ch)]
} else {
Vec::new()
};
let c = c.to_base32();
to_channel.push(("apply", &c));
debug!("url {:?} {:?}", url, to_channel);
self.client
.post(&url)
.query(&to_channel)
.body(change)
.send()
.await?;
progress.inc(1);
libpijul::changestore::filesystem::pop_filename(&mut local);