Rename option from download-multiple-images to download-multiple-files

This commit is contained in:
2022-07-17 04:43:30 +00:00
committed by GitHub
parent 969c898586
commit d6be8107ee
4 changed files with 19 additions and 19 deletions

View File

@@ -307,7 +307,7 @@ impl Main {
} else {
println!("{}", gettext("Warning: Failed to get illust's type."));
}
if pages_data.is_some() && helper.download_multiple_images() {
if pages_data.is_some() && helper.download_multiple_files() {
let mut np = 0u16;
let pages_data = pages_data.as_ref().unwrap();
let progress_bars = get_progress_bar();
@@ -546,7 +546,7 @@ impl Main {
.save(&json_file)
.try_err(gettext("Failed to save post data to file."))?;
let tasks = TaskManager::default();
let download_mutiple_images = helper.download_multiple_images();
let download_multiple_files = helper.download_multiple_files();
match post {
FanboxPost::Article(article) => {
let article = Arc::new(article);
@@ -583,7 +583,7 @@ impl Main {
Arc::clone(&base),
))
.await;
if !download_mutiple_images {
if !download_multiple_files {
tasks.join().await;
}
np += 1;
@@ -610,7 +610,7 @@ impl Main {
Arc::clone(&base),
))
.await;
if !download_mutiple_images {
if !download_multiple_files {
tasks.join().await;
}
}
@@ -641,7 +641,7 @@ impl Main {
Arc::clone(&base),
))
.await;
if !download_mutiple_images {
if !download_multiple_files {
tasks.join().await;
}
np += 1;

View File

@@ -323,9 +323,9 @@ impl OptHelper {
String::from("[{elapsed_precise}] [{wide_bar:.green/yellow}] {bytes}/{total_bytes} ({bytes_per_sec}, {eta}) {msg:40}")
}
/// Return whether to download multiple images at the same time.
pub fn download_multiple_images(&self) -> bool {
match self.opt.get_ref().download_multiple_images {
/// Return whether to download multiple files at the same time.
pub fn download_multiple_files(&self) -> bool {
match self.opt.get_ref().download_multiple_files {
Some(r) => {
return r;
}
@@ -334,12 +334,12 @@ impl OptHelper {
if self
.settings
.get_ref()
.have_bool("download-multiple-images")
.have_bool("download-multiple-files")
{
return self
.settings
.get_ref()
.get_bool("download-multiple-images")
.get_bool("download-multiple-files")
.unwrap();
}
false

View File

@@ -75,8 +75,8 @@ pub struct CommandOpts {
pub update_exif: bool,
/// Whether to enable progress bar
pub use_progress_bar: Option<UseOrNot>,
/// Whether to download multiple images at the same time
pub download_multiple_images: Option<bool>,
/// Whether to download multiple files at the same time
pub download_multiple_files: Option<bool>,
/// Max retry count when downloading failed.
pub download_retry: Option<i64>,
/// Retry interval when downloading files.
@@ -113,7 +113,7 @@ impl CommandOpts {
#[cfg(feature = "exif")]
update_exif: false,
use_progress_bar: None,
download_multiple_images: None,
download_multiple_files: None,
download_retry: None,
download_retry_interval: None,
multiple_threads_download: None,
@@ -351,10 +351,10 @@ pub fn parse_cmd() -> Option<CommandOpts> {
);
opts.opt(
"",
"download-multiple-images",
"download-multiple-files",
format!(
"{} ({} {})",
gettext("Download multiple images at the same time."),
gettext("Download multiple files at the same time."),
gettext("Default:"),
"yes"
)
@@ -559,13 +559,13 @@ pub fn parse_cmd() -> Option<CommandOpts> {
}
re.as_mut().unwrap().use_progress_bar = Some(r.unwrap());
}
match parse_optional_opt(&result, "download-multiple-images", true, parse_bool) {
Ok(b) => re.as_mut().unwrap().download_multiple_images = b,
match parse_optional_opt(&result, "download-multiple-files", true, parse_bool) {
Ok(b) => re.as_mut().unwrap().download_multiple_files = b,
Err(e) => {
println!(
"{} {}",
gettext("Failed to parse <opt>:")
.replace("<opt>", "download-multiple-images")
.replace("<opt>", "download-multiple-files")
.as_str(),
e
);

View File

@@ -28,7 +28,7 @@ pub fn get_settings_list() -> Vec<SettingDes> {
SettingDes::new("update-exif", gettext("Add/Update exif information to image files even when overwrite are disabled."), JsonValueType::Boolean, None).unwrap(),
SettingDes::new("progress-bar-template", gettext("Progress bar's template. See <here> for more informations.").replace("<here>", "https://docs.rs/indicatif/latest/indicatif/#templates").as_str(), JsonValueType::Str, Some(check_nonempty_str)).unwrap(),
SettingDes::new("use-progress-bar", gettext("Whether to enable progress bar."), JsonValueType::Multiple, Some(check_user_or_not)).unwrap(),
SettingDes::new("download-multiple-images", gettext("Download multiple images at the same time."), JsonValueType::Boolean, None).unwrap(),
SettingDes::new("download-multiple-files", gettext("Download multiple files at the same time."), JsonValueType::Boolean, None).unwrap(),
SettingDes::new("download-retry", gettext("Max retry count if download failed."), JsonValueType::Number, Some(check_i64)).unwrap(),
SettingDes::new("download-retry-interval", gettext("The interval (in seconds) between two retries when downloading files."), JsonValueType::Multiple, Some(check_retry_interval)).unwrap(),
SettingDes::new("multiple-threads-download", gettext("Whether to enable multiple threads download."), JsonValueType::Boolean, None).unwrap(),