27PYHR6LO4M4RMSMLVMUKSYNQ72V6RRMRXLYQI3JA3LBHJO747YAC
let latest_touch = get_latest_touch(changes, txn, &channel, output_item.pos)?;
let (_, latest_touch) =
crate::fs::get_latest_touch(txn, &channel, output_item.pos)?;
let latest_touch = {
let ext = txn.get_external(latest_touch)?.unwrap();
let c = changes.get_header(&ext).map_err(ArchiveError::P)?;
c.timestamp.timestamp() as u64
};
}
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)
}
pub fn get_latest_touch<'a, T: ChannelTxnT + DepsTxnT<DepsError = <T as GraphTxnT>::GraphError>>(
txn: &T,
channel: &T::Channel,
pos: Position<ChangeId>,
) -> Result<(u64, ChangeId), TxnErr<T::GraphError>> {
let mut latest_change = 0;
let mut id = ChangeId::ROOT;
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_change = t;
id = change;
}
}
continue_ = true;
}
}
}
if let Some(l) = log_iter.next() {
debug!("int = {:?}", l);
let (n, (int, _)) = l?;
if txn.get_touched_files(pos, Some(int))?.is_some() {
id = int;
latest_change = n;
break;
}
continue_ = true;
}
}
Ok((latest_change, id))