Skip to content

Commit 4c90a6b

Browse files
committed
add extra logs on diskspace when downloading
1 parent 3b3d1ba commit 4c90a6b

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-client-cli/src/commands/cardano_db/download/v2.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,17 @@ impl PreparedCardanoDbV2Download {
236236
) -> MithrilResult<()> {
237237
progress_printer.report_step(step_number, "Checking local disk info…")?;
238238

239+
let free_space = fs2::available_space(&restoration_options.db_dir)?;
240+
let total_size_uncompressed =
241+
Self::compute_required_disk_space_for_snapshot(cardano_db, restoration_options);
242+
243+
let message = format!(
244+
"free space is {} bytes, required space for the snapshot is {} bytes",
245+
free_space, total_size_uncompressed
246+
);
247+
248+
progress_printer.report_step(step_number, &message)?;
249+
239250
CardanoDbDownloadChecker::ensure_dir_exist(&restoration_options.db_dir)?;
240251
if let Err(e) = CardanoDbDownloadChecker::check_prerequisites_for_uncompressed_data(
241252
&restoration_options.db_dir,

mithril-client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ thiserror = { workspace = true }
8080
tokio = { workspace = true }
8181
uuid = { version = "1.21.0", features = ["v4"] }
8282
zstd = { version = "0.13.3", optional = true }
83+
fs2 = "0.4.3"
8384

8485
[target.'cfg(not(target_family = "wasm"))'.dependencies]
8586
mithril-aggregator-discovery = { path = "../internal/mithril-aggregator-discovery", version = "0.1" }

mithril-client/src/cardano_database_client/download_unpack/download_task.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ impl DownloadTask {
4848
let mut download_succeeded = false;
4949

5050
for location_to_try in &self.locations_to_try {
51+
//print a log with space disk of target dir before downloading
52+
let free_space = fs2::available_space(&target_dir)?;
53+
slog::warn!(
54+
logger,
55+
"Attempting to download {} from location {:?} (available disk space: {} bytes)",
56+
self.name(),
57+
location_to_try.file_downloader_uri,
58+
free_space
59+
);
60+
5161
let downloaded = location_to_try
5262
.file_downloader
5363
.download_unpack(

0 commit comments

Comments
 (0)