| 35 | |
| 36 | impl PatchMemory { |
| 37 | pub fn open(repo_root: &Path) -> Result<Self> { |
| 38 | let root = repo_root.join(PATCH_DIR); |
| 39 | fs::create_dir_all(&root)?; |
| 40 | let log = root.join(PATCH_LOG_FILE); |
| 41 | let stats = root.join(PATCH_STATS_FILE); |
| 42 | let perf = root.join(MODEL_PERF_FILE); |
| 43 | if !log.exists() { |
| 44 | File::create(&log)?; |
| 45 | } |
| 46 | if !stats.exists() { |
| 47 | fs::write(&stats, "{}")?; |
| 48 | } |
| 49 | if !perf.exists() { |
| 50 | fs::write(&perf, "[]")?; |
| 51 | } |
| 52 | Ok(Self { root }) |
| 53 | } |
| 54 | |
| 55 | pub fn new_record_id() -> String { |
| 56 | let ts = SystemTime::now() |