pub struct Store { /* private fields */ }Expand description
Where pictures are kept, and how much room they may take.
Implementations§
Source§impl Store
impl Store
Sourcepub fn new(root: PathBuf, max_total_bytes: u64) -> Self
pub fn new(root: PathBuf, max_total_bytes: u64) -> Self
<state_dir>/attachments, or the [attachments] dir override.
Sourcepub fn with_helper(self, helper: Option<Helper>) -> Self
pub fn with_helper(self, helper: Option<Helper>) -> Self
The same store with a named helper — a test’s only way to exercise the Pillow branch on a
machine that also has ImageMagick (#499 acceptance 6).
pub fn root(&self) -> &Path
Sourcepub fn keep(
&self,
session: &str,
name: &str,
mime: &str,
bytes: &[u8],
) -> Result<Stored, String>
pub fn keep( &self, session: &str, name: &str, mime: &str, bytes: &[u8], ) -> Result<Stored, String>
Keep a picture: the original untouched, and a working copy that fits the wire.
Bytes are written once per distinct picture — the file name is the hash, so a re-sent picture is a touch for the LRU clock and no write.
Sourcepub fn total_bytes(&self) -> u64
pub fn total_bytes(&self) -> u64
Bytes on disk across every session.
Sourcepub fn prune(&self, need: u64) -> Result<u64, String>
pub fn prune(&self, need: u64) -> Result<u64, String>
Delete the oldest files until need bytes are freed, or nothing is left to delete.
Least-recently-used, not per-session: the budget is about the disk, and a session nobody has opened in a month is the right thing to lose. Returns the bytes freed.