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channel_name, &header, &mut w)?;
libpijul::changestore::filesystem::push_filename(&mut tag_path, &h);
tag_path.set_extension("tag");
let h: libpijul::Merkle =
libpijul::tag::from_channel(&*txn.read(), &channel_name, &header, &mut w)?;
libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &h);
let h = if let Some(h) = libpijul::Hash::from_base32(tag.as_bytes()) {
libpijul::changestore::filesystem::push_filename(&mut tag_path, &h);
tag_path.set_extension("tag");
let h = if let Some(h) = libpijul::Merkle::from_base32(tag.as_bytes()) {
libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &h);
let h = if let Some(h) = libpijul::Hash::from_base32(tag.as_bytes()) {
libpijul::changestore::filesystem::push_filename(&mut tag_path, &h);
tag_path.set_extension("tag");
let h = if let Some(h) = libpijul::Merkle::from_base32(tag.as_bytes()) {
libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &h);
let (_, h) = t?;
let h: libpijul::Hash = h.into();
libpijul::changestore::filesystem::push_filename(&mut tag_path, &h);
tag_path.set_extension("tag");
let mut f = libpijul::tag::OpenTagFile::open(&tag_path)?;
let t = (*t?).into();
let (_, m) = txn.get_changes(&channel, t)?.unwrap();
libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &m);
let mut f = libpijul::tag::OpenTagFile::open(&tag_path, &m)?;
let header = bincode::deserialize(&off).map_err(TagError::BincodeDe)?;
Ok(OpenTagFile { header, file })
let header: FileHeader = bincode::deserialize(&off).map_err(TagError::BincodeDe)?;
if &header.state == expected {
Ok(OpenTagFile { header, file })
} else {
Err(TagError::WrongHash {
expected: *expected,
got: header.state,
})
}
}
pub fn check(&mut self, expected: &Hash) -> Result<(), TagError> {
let mut hasher = Hasher::default();
self.file.seek(SeekFrom::Start(0))?;
let mut buf = Vec::new();
// Reading the FileHeader
buf.resize(self.header.header as usize, 0);
self.file.read_exact(&mut buf)?;
hasher.update(&buf);
// Reading the Header
buf.resize((self.header.channel - self.header.header) as usize, 0);
self.file.read_exact(&mut buf)?;
hasher.update(&buf);
// Reading the Header
buf.resize((self.header.unhashed - self.header.channel) as usize, 0);
self.file.read_exact(&mut buf)?;
hasher.update(&buf);
let got = hasher.finish();
if &got != expected {
Err(TagError::WrongHash {
expected: *expected,
got,
})
} else {
Ok(())
}
fn get_tags(
&self,
channel: &Self::Tags,
c: &L64,
) -> Result<Option<&SerializedHash>, TxnErr<Self::GraphError>> {
use crate::pristine::sanakirja::UDb;
let db: UDb<L64, SerializedHash> = UDb::from_page(*channel);
match ::sanakirja::btree::get(self, &db, c, None)? {
Some((k, v)) if k == c => Ok(Some(v)),
_ => Ok(None),
type TagsCursor =
::sanakirja::btree::cursor::Cursor<L64, (), P<L64, ()>>;
fn is_tagged(&self, tags: &Self::Tags, t: u64) -> Result<bool, TxnErr<Self::GraphError>> {
use crate::pristine::sanakirja::Db;
let db: Db<L64, ()> = Db::from_page(*tags);
let t: L64 = t.into();
match ::sanakirja::btree::get(self, &db, &t, None)? {
Some((k, _)) => Ok(k == &t),
_ => Ok(false)
type Tags = UDb<L64, SerializedHash>;
fn get_tags(
&self,
channel: &Self::Tags,
c: &L64,
) -> Result<Option<&SerializedHash>, TxnErr<Self::GraphError>> {
match btree::get(&self.txn, channel, c, None)? {
Some((k, v)) if k == c => Ok(Some(v)),
_ => Ok(None),
type Tags = Db<L64, ()>;
fn is_tagged(&self, tags: &Self::Tags, t: u64) -> Result<bool, TxnErr<Self::GraphError>> {
let t: L64 = t.into();
match btree::get(&self.txn, tags, &t, None)? {
Some((k, _)) => Ok(k == &t),
_ => Ok(false)
initialized_cursor!(tags, L64, SerializedHash, ChannelTxnT, GraphError);
initialized_rev_cursor!(tags, L64, SerializedHash, ChannelTxnT, GraphError);
impl<'a, T: ChannelTxnT> Iterator for crate::pristine::RevCursor<T, &'a T, T::TagsCursor, L64, ()>
{
type Item = Result<&'a L64, TxnErr<T::GraphError>>;
fn next(&mut self) -> Option<Self::Item> {
match self.txn.cursor_tags_prev(&mut self.cursor) {
Ok(Some(x)) => Some(Ok(x)),
Ok(None) => None,
Err(e) => Some(Err(e)),
}
}
}
impl<'a, T: ChannelTxnT>
crate::pristine::Cursor<T, &'a T, T::TagsCursor, L64, ()>
{
pub fn prev(&mut self) -> Option<Result<u64, TxnErr<T::GraphError>>> {
match self.txn.cursor_tags_prev(&mut self.cursor) {
Ok(Some(x)) => Some(Ok((*x).into())),
Ok(None) => None,
Err(e) => Some(Err(e)),
}
}
}
impl<'a, T: ChannelTxnT> Iterator for crate::pristine::Cursor<T, &'a T, T::TagsCursor, L64, ()>
{
type Item = Result<u64, TxnErr<T::GraphError>>;
fn next(&mut self) -> Option<Self::Item> {
match self.txn.cursor_tags_next(&mut self.cursor) {
Ok(Some(x)) => Some(Ok((*x).into())),
Ok(None) => None,
Err(e) => Some(Err(e)),
}
}
}