From d4d1503b1c0fd02a15ef3c3b8f377c33ee800168 Mon Sep 17 00:00:00 2001 From: gluax <16431709+gluax@users.noreply.github.com> Date: Wed, 1 May 2024 13:15:16 -0600 Subject: [PATCH] fix(snops): create empty ledger dir during connect --- crates/snops/src/schema/error.rs | 2 ++ crates/snops/src/schema/storage.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/crates/snops/src/schema/error.rs b/crates/snops/src/schema/error.rs index e10b1ae9..fcb45e82 100644 --- a/crates/snops/src/schema/error.rs +++ b/crates/snops/src/schema/error.rs @@ -25,6 +25,8 @@ pub enum StorageError { FailedToFetchGenesis(StorageId, Url, #[source] reqwest::Error), #[error("writing genesis block id: `{0}`: {1}")] FailedToWriteGenesis(StorageId, #[source] std::io::Error), + #[error("creating ledger dir id: `{0}`: {1}")] + FailedToCreateLedgerDir(StorageId, #[source] std::io::Error), #[error("taring ledger id: `{0}`: {1}")] FailedToTarLedger(StorageId, #[source] std::io::Error), #[error("the specified storage ID {0} doesn't exist, and no generation params were specified")] diff --git a/crates/snops/src/schema/storage.rs b/crates/snops/src/schema/storage.rs index 1f30f65f..3b59fc40 100644 --- a/crates/snops/src/schema/storage.rs +++ b/crates/snops/src/schema/storage.rs @@ -286,6 +286,10 @@ impl Document { .await .map_err(err)?; + tokio::fs::create_dir(base.join(LEDGER_BASE_DIR)) + .await + .map_err(|e| StorageError::FailedToCreateLedgerDir(id, e))?; + tokio::fs::write(&output, res) .await .map_err(|e| StorageError::FailedToWriteGenesis(id, e))?;