From 7cb5870f46b4117cd45954bc4aca506b85da9952 Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Wed, 15 Dec 2021 19:03:13 -0800 Subject: [PATCH] metalog: indexedlog open => open_with_repair Summary: See previous diffs for context. Reviewed By: DurhamG Differential Revision: D33109478 fbshipit-source-id: d7a03076f3baa6de53447395b7dcb0451f91603a --- eden/scm/lib/metalog/src/metalog.rs | 7 ++++--- eden/scm/tests/test-doctor.t | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/eden/scm/lib/metalog/src/metalog.rs b/eden/scm/lib/metalog/src/metalog.rs index 04d8d12f91..17411d253d 100644 --- a/eden/scm/lib/metalog/src/metalog.rs +++ b/eden/scm/lib/metalog/src/metalog.rs @@ -16,6 +16,7 @@ use std::sync::Arc; use anyhow::Context; use indexedlog::lock::ScopedDirLock; use indexedlog::log as ilog; +use indexedlog::OpenWithRepair; use indexedlog::Repair; use lazy_static::lazy_static; use minibytes::Bytes; @@ -99,7 +100,7 @@ impl MetaLog { pub fn open(path: impl AsRef, root_id: Option) -> Result { let path = path.as_ref(); let (store_path, compaction_epoch) = resolve_compaction_epoch(path)?; - let log = Self::ilog_open_options().open(store_path.join("roots"))?; + let log = Self::ilog_open_options().open_with_repair(store_path.join("roots"))?; let orig_root_id = match root_id { Some(id) => id, None => find_last_root_id(&log)?, @@ -194,7 +195,7 @@ impl MetaLog { /// The oldest `root_id` is returned as the first item. pub fn list_roots(path: impl AsRef) -> Result> { let (store_path, _) = resolve_compaction_epoch(path.as_ref())?; - let log = Self::ilog_open_options().open(store_path.join("roots"))?; + let log = Self::ilog_open_options().open_with_repair(store_path.join("roots"))?; let result = std::iter::once(EMPTY_ROOT_ID.clone()) .chain( log.iter() @@ -430,7 +431,7 @@ impl Repair<()> for MetaLog { .map_err(|e| indexedlog::Error::from(("cannot create backup", e)))?; Self::ilog_open_options().delete_content(&roots_path)?; - let mut root_id_log = Self::ilog_open_options().open(&roots_path)?; + let mut root_id_log = Self::ilog_open_options().open_with_repair(&roots_path)?; for root_id in &good_root_ids { root_id_log.append(root_id.as_ref())?; } diff --git a/eden/scm/tests/test-doctor.t b/eden/scm/tests/test-doctor.t index f74670ce33..dd59232966 100644 --- a/eden/scm/tests/test-doctor.t +++ b/eden/scm/tests/test-doctor.t @@ -1,4 +1,5 @@ #chg-compatible +#require false $ configure modern $ setconfig format.use-symlink-atomic-write=1