(
dir: impl AsRef<Path>,
limits: ArtifactStoreLimits,
)
| 128 | } |
| 129 | |
| 130 | pub fn load_from_dir_with_limits( |
| 131 | dir: impl AsRef<Path>, |
| 132 | limits: ArtifactStoreLimits, |
| 133 | ) -> Result<Self> { |
| 134 | let path = artifact_manifest_path(dir.as_ref()); |
| 135 | if !path.exists() { |
| 136 | return Ok(Self::with_limits(limits)); |
| 137 | } |
| 138 | |
| 139 | let json = std::fs::read_to_string(&path) |
| 140 | .with_context(|| format!("failed to read artifact manifest '{}'", path.display()))?; |
| 141 | let snapshot: ArtifactStoreSnapshot = |
| 142 | serde_json::from_str(&json).context("failed to parse artifact store snapshot")?; |
| 143 | let store = Self::with_limits(limits); |
| 144 | for artifact in snapshot.artifacts { |
| 145 | store.put(artifact); |
| 146 | } |
| 147 | Ok(store) |
| 148 | } |
| 149 | |
| 150 | fn enforce_limits(&self, state: &mut ArtifactStoreState) { |
| 151 | while state.artifacts.len() > self.limits.max_artifacts |
nothing calls this directly
no test coverage detected