Skip to content

Commit b0db8d7

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

4 files changed

Lines changed: 25 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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,16 @@ impl PreparedCardanoDbV2Download {
237237
progress_printer.report_step(step_number, "Checking local disk info…")?;
238238

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

mithril-client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ uuid = { version = "1.21.0", features = ["v4"] }
8282
zstd = { version = "0.13.3", optional = true }
8383

8484
[target.'cfg(not(target_family = "wasm"))'.dependencies]
85+
fs2 = "0.4.3"
8586
mithril-aggregator-discovery = { path = "../internal/mithril-aggregator-discovery", version = "0.1" }
8687
mithril-cardano-node-internal-database = { path = "../internal/cardano-node/mithril-cardano-node-internal-database", version = "0.1" }
8788
rand = { version = "0.10.0" }

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

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

5050
for location_to_try in &self.locations_to_try {
51+
#[cfg(not(target_family = "wasm"))]
52+
{
53+
//print a log with space disk of target dir before downloading
54+
let free_space = fs2::available_space(target_dir)?;
55+
slog::warn!(
56+
logger,
57+
"Attempting to download {} from location {:?} (available disk space: {} bytes)",
58+
self.name(),
59+
location_to_try.file_downloader_uri,
60+
free_space
61+
);
62+
}
63+
5164
let downloaded = location_to_try
5265
.file_downloader
5366
.download_unpack(

0 commit comments

Comments
 (0)