diff --git a/README.md b/README.md index fe0e949..e71e03e 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ Retrieve Ferload download link(s) ✅ Compute total average expected download size ✅ -The total expected average download size will be 4 GB do you agree ? [yes]: +The total average expected download size will be 4GB do you want to continue (your available disk space is: 87 GB) ? [yes] FIL0000010 [##################################################] 0 / 0 MB (100%) 📦 FIL0000002 [##################################################] 125 / 125 MB (100%) 📦 @@ -138,6 +138,13 @@ FIL0000006 [##################################################] 150 / 150 Total downloaded files: 12 located here: ./data ``` + +*Note: in case the tool can't compute the total average expected download size, the following message will be displayed:* +``` +Failed to compute total average expected download size, reason: Future timed out after [60 seconds] +You can still proceed with the download, verify you have remaining disk-space available. ✅ +``` + # Technical ## Manifest file diff --git a/src/main/scala/ca/ferlab/ferload/client/commands/Download.scala b/src/main/scala/ca/ferlab/ferload/client/commands/Download.scala index fc1b8b2..f77a599 100644 --- a/src/main/scala/ca/ferlab/ferload/client/commands/Download.scala +++ b/src/main/scala/ca/ferlab/ferload/client/commands/Download.scala @@ -90,17 +90,29 @@ class Download(userConfig: UserConfig, } val totalExpectedDownloadSize = CommandBlock("Compute total average expected download size", successEmoji, padding) { - s3.getTotalExpectedDownloadSize(links, appConfig.getLong("size-estimation-timeout")) + Try(s3.getTotalExpectedDownloadSize(links, appConfig.getLong("size-estimation-timeout"))) match { + case Success(size) => size + case Failure(e) => { + println() + println() + println(s"Failed to compute total average expected download size, reason: ${e.getMessage}") + print(s"You can still proceed with the download, verify you have remaining disk-space available.") + 0L + } + } } + val totalExpectedDownloadSizeStr = if(totalExpectedDownloadSize > 0) FileUtils.byteCountToDisplaySize(totalExpectedDownloadSize) else "-" + val usableSpace = s3.getTotalAvailableDiskSpaceAt(outputDir) + val usableSPaceStr = FileUtils.byteCountToDisplaySize(usableSpace) + val downloadAgreement = appConfig.getString("download-agreement") val agreedToDownload = commandLine.readLine(s"The total average expected download size will be " + - s"${FileUtils.byteCountToDisplaySize(totalExpectedDownloadSize)} do you want to continue ? [$downloadAgreement]") + s"$totalExpectedDownloadSizeStr do you want to continue (your available disk space is: $usableSPaceStr) ? [$downloadAgreement]") println() if (agreedToDownload.equals(downloadAgreement) || StringUtils.isBlank(agreedToDownload)) { - val usableSpace = s3.getTotalAvailableDiskSpaceAt(outputDir) if (usableSpace < totalExpectedDownloadSize) { throw new IllegalStateException(s"Not enough disk space available $usableSpace < $totalExpectedDownloadSize") }