fn get_latest_touch<
'a,
T: ChannelTxnT + DepsTxnT<DepsError = <T as GraphTxnT>::GraphError>,
P: ChangeStore,
A: std::error::Error + 'static,
>(
changes: &P,
txn: &T,
channel: &T::Channel,
pos: Position<ChangeId>,
) -> Result<u64, ArchiveError<P::Error, T::GraphError, A>> {
let mut latest_touch = 0;
let mut latest_change = 0;
let mut touch_iter = Some(txn.iter_touched(pos)?);
let mut log_iter = changeid_rev_log(txn, &channel, None)?;
let mut continue_ = true;
while continue_ {
continue_ = false;
if let Some(ref mut it) = touch_iter {
if let Some(c) = it.next() {
debug!("inode, change = {:?}", c);
let (inode, change) = c?;
if inode > pos {
touch_iter = None;
} else if inode == pos {
if let Some(t) = txn.get_changeset(T::changes(&channel), change)? {
if t > latest_change || latest_touch == 0 {
latest_change = t;
let ext = txn.get_external(change)?.unwrap();
let c = changes.get_header(&ext).map_err(ArchiveError::P)?;
latest_touch = c.timestamp.timestamp() as u64
}
}
continue_ = true;
}
}
}
if let Some(l) = log_iter.next() {
debug!("int = {:?}", l);
let (_, (int, _)) = l?;
if txn.get_touched_files(pos, Some(int))?.is_some() {
let ext = txn.get_external(int)?.unwrap();
let c = changes.get_header(&ext).map_err(ArchiveError::P)?;
latest_touch = c.timestamp.timestamp() as u64;
break;
}
continue_ = true;
}
}
Ok(latest_touch)
}