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PU7AFTRUOTX7HZIAV4AZKYEQC
3KRGVQFUWFHPOGZOXVTJYNCM4XBRVYITAEOVPKBSAZ5GZIUO5KVQC
XA23FMQM2AI7RMR36AYN7UNP2D5JWVJMJPHURWZO7URM7H46PU6AC
2RXOCWUWOGHEKHT5W73LAHJSOZVRTOGS7BWLSIGEEEBJGMCZBXQAC
QE64ATLZWMKHYABCD3VA547PYXCK6YN3K7RE2TX3SCQNKG7XLVAQC
while to_download.contains(&h) {
debug!("waiting for {:?}", h);
if let Some((h, _)) = recv.recv().await {
debug!("recv {:?}", h);
to_download.remove(&h);
} else {
break;
}
}
async fn download_changes_rec(
&mut self,
repo: &mut Repository,
send_hash: tokio::sync::mpsc::UnboundedSender<CS>,
mut recv_signal: tokio::sync::mpsc::Receiver<(CS, bool)>,
pro_n: usize,
mut waiting: usize,
) -> Result<
(
tokio::task::JoinHandle<Result<(), anyhow::Error>>,
tokio::sync::mpsc::Receiver<CS>,
),
anyhow::Error,
> {
let (send_ready, recv_ready) = tokio::sync::mpsc::channel(100);
let mut change_path = repo.changes_dir.clone();
let mut dep_path = repo.changes_dir.clone();
let changes = repo.changes.clone();
let t = tokio::spawn(async move {
let mut ready = Vec::new();
while let Some((hash, follow)) = recv_signal.recv().await {
if let CS::Change(hash) = hash {
waiting -= 1;
if follow {
libpijul::changestore::filesystem::push_filename(&mut change_path, &hash);
std::fs::create_dir_all(change_path.parent().unwrap())?;
use libpijul::changestore::ChangeStore;
let mut needs_dep = false;
for dep in changes.get_dependencies(&hash)? {
let dep: libpijul::pristine::Hash = dep;
libpijul::changestore::filesystem::push_filename(&mut dep_path, &dep);
let has_dep = std::fs::metadata(&dep_path).is_ok();
libpijul::changestore::filesystem::pop_filename(&mut dep_path);
if !has_dep {
needs_dep = true;
PROGRESS.borrow_mut().unwrap()[pro_n].incr_len();
send_hash.send(CS::Change(dep))?;
waiting += 1
}
}
libpijul::changestore::filesystem::pop_filename(&mut change_path);
if !needs_dep {
send_ready.send(CS::Change(hash)).await?;
} else {
ready.push(CS::Change(hash))
}
} else {
send_ready.send(CS::Change(hash)).await?;
}
}
if waiting == 0 {
break;
}
}
for r in ready {
send_ready.send(r).await?;
}
std::mem::drop(recv_signal);
Ok(())
});
Ok((t, recv_ready))
}
while let Some((hash, follow)) = recv_signal.recv().await {
if let CS::Change(hash) = hash {
waiting -= 1;
if follow {
libpijul::changestore::filesystem::push_filename(&mut change_path, &hash);
std::fs::create_dir_all(change_path.parent().unwrap())?;
use libpijul::changestore::ChangeStore;
hashes.push(CS::Change(hash));
for dep in repo.changes.get_dependencies(&hash)? {
let dep: libpijul::pristine::Hash = dep;
PROGRESS.borrow_mut().unwrap()[pro_n].incr_len();
send_hash.send(CS::Change(dep))?;
waiting += 1
}
libpijul::changestore::filesystem::pop_filename(&mut change_path);
}
}
if waiting == 0 {
break
}
}
std::mem::drop(recv_signal);
std::mem::drop(send_hash);
libpijul::output::output_repository_no_pending(
&repo.working_copy,
&repo.changes,
&txn,
&channel,
"",
true,
None,
1, // num_cpus::get(),
self.salt.unwrap_or(0),
)?;
if self.partial_paths.is_empty() {
libpijul::output::output_repository_no_pending(
&repo.working_copy,
&repo.changes,
&txn,
&channel,
"",
true,
None,
1, // num_cpus::get(),
self.salt.unwrap_or(0),
)?;
} else {
for p in self.partial_paths.iter() {
libpijul::output::output_repository_no_pending(
&repo.working_copy,
&repo.changes,
&txn,
&channel,
p,
true,
None,
1, // num_cpus::get(),
self.salt.unwrap_or(0),
)?;
}
}