1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Disk-usage accounting for the local spool directory.
//!
//! Provides byte-level size calculations so the storage manager
//! can warn or reject when the spool exceeds its budget.
//!
//! # Examples
//!
//! ```ignore
//! let bytes = spool_usage_bytes(Path::new("/tmp/spool")).await?;
//! println!("spool uses {bytes} bytes");
//! ```
use Result;
use Path;
/// Sum the byte sizes of all `.jsonl` files in `dir`.
///
/// Returns `0` when the directory does not exist rather than
/// failing, so callers can check usage before the spool is
/// first created.
///
/// # Examples
///
/// ```ignore
/// let bytes = spool_usage_bytes(&spool_dir).await?;
/// if bytes > max_bytes {
/// tracing::warn!("spool over budget");
/// }
/// ```
pub async