diff --git a/src/server/data.rs b/src/server/data.rs index ab5dad1..a79f180 100644 --- a/src/server/data.rs +++ b/src/server/data.rs @@ -5,6 +5,9 @@ use std::{ borrow::Cow, error, fmt, + path::PathBuf, + fs, + num::NonZeroI32, }; use generational_arena::{ Arena, Index, @@ -46,6 +49,17 @@ pub enum Data /// A binary blob Binary(Vec), + /// A UTF-8 text string outsourced to a file. + /// + /// The file path is this ID inside the data dir. It may be subject to caching later down the line, and will require deleting when an Atom of this type is removed. + /// The files corresponding to these entries should be lazy-loaded (as open `tokio::fs::File`s) into a `DelayQueue` for caching. + TextFile(uuid::Uuid), + /// A binary blob outsourced to a file. + /// + /// The file path is this ID inside the data dir. It may be subject to caching later down the line, and will require deleting when an Atom of this type is removed. + /// The files corresponding to these entries should be lazy-loaded (as open `tokio::fs::File`s) into a `DelayQueue` for caching. + BinaryFile(uuid::Uuid), + /// A reference index to an item within the same `Datamap` as this one. RelativeRef(Index), /// A reference to an item N deep within nested `Map` elements. diff --git a/src/server/user/user.rs b/src/server/user/user.rs index 3e613e4..3066bf0 100644 --- a/src/server/user/user.rs +++ b/src/server/user/user.rs @@ -74,13 +74,14 @@ impl<'u> iter::DoubleEndedIterator for Groups<'u> { fn next_back(&mut self) -> Option { - if self.0 == 0 { - None + if self.0 == 0 || self.0 >= self.1.len() { + self.0 = self.1.len()-1; } else { self.0-=1; - debug_assert!(self.0 iter::ExactSizeIterator for Groups<'u>{}