Forwarding SSH stderr, and progress bar for push

[?]
Nov 27, 2020, 6:44 PM
367UBQ6KNAKUEWG32R4QRJ6H7IE7NAZFOPTC3ZOE4Z6E44RV3ISQC

Dependencies

  • [2] YS2HLPX6 Don't propose an empty list of changes to push
  • [3] VMPAOJS2 Don't output after pushing to a local channel
  • [4] Q45QHPO4 Feedback on network stuff
  • [5] 76PCXGML Pushing to, and pulling from the local repository
  • [6] UDHP4ZVB Fixing SSH asynchronicity issues
  • [7] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [*] FBXYP7QM Forgot to add remote::http
  • [*] 5HF7C67M push/pull: fixed "changes" arguments

Change contents

  • edit in pijul/src/remote/ssh.rs at line 315
    [5.1255]
    [5.1255]
    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))
    })
    }
    }
  • edit in pijul/src/remote/ssh.rs at line 676
    [5.44567]
    [5.44567]
    let progress = ProgressBar::new(changes.len() as u64);
    progress.println("Uploading changes");
  • edit in pijul/src/remote/ssh.rs at line 695
    [5.45306]
    [5.45306]
    progress.inc(1);
  • edit in pijul/src/remote/ssh.rs at line 698
    [5.45389]
    [5.45389]
    progress.finish();
  • replacement in pijul/src/remote/mod.rs at line 390
    [5.2441][5.65199:65227](),[5.65199][5.65199:65227]()
    mut local: PathBuf,
    [5.2441]
    [5.65227]
    local: PathBuf,
  • replacement in pijul/src/remote/mod.rs at line 397
    [5.65529][5.65529:66522]()
    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(())
    }
    [5.65529]
    [5.2442]
    RemoteRepo::Http(ref h) => h.upload_changes(local, to_channel, changes).await,
  • edit in pijul/src/remote/http.rs at line 6
    [4.1253]
    [9.87]
    use log::debug;
  • edit in pijul/src/remote/http.rs at line 55
    [4.1501]
    [4.1501]
    }
    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);
  • edit in pijul/src/remote/http.rs at line 88
    [4.1511]
    [9.1359]
    progress.finish();
  • edit in pijul/src/commands/pushpull.rs at line 118
    [5.114511]
    [3.153]
    let mut stderr = std::io::stderr();
  • edit in pijul/src/commands/pushpull.rs at line 213
    [2.35]
    [2.35]
    writeln!(stderr, "Nothing to push")?;
  • edit in pijul/src/commands/pushpull.rs at line 257
    [10.1230]
    [10.1230]
    writeln!(stderr, "Nothing to push")?;