mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-06-23 20:27:00 +08:00
Remove all spin_on
This commit is contained in:
20
Cargo.lock
generated
20
Cargo.lock
generated
@@ -809,6 +809,15 @@ version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.2"
|
||||
@@ -1237,6 +1246,7 @@ dependencies = [
|
||||
"http-content-range",
|
||||
"indicatif",
|
||||
"int-enum",
|
||||
"itertools",
|
||||
"json",
|
||||
"lazy_static",
|
||||
"link-cplusplus",
|
||||
@@ -1245,7 +1255,6 @@ dependencies = [
|
||||
"proc_macros",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"spin_on",
|
||||
"tokio",
|
||||
"url",
|
||||
"urlparse",
|
||||
@@ -1564,15 +1573,6 @@ version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||
|
||||
[[package]]
|
||||
name = "spin_on"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "076e103ed41b9864aa838287efe5f4e3a7a0362dd00671ae62a212e5e4612da2"
|
||||
dependencies = [
|
||||
"pin-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
|
||||
@@ -20,6 +20,7 @@ http = "0.2"
|
||||
http-content-range = "0.1"
|
||||
indicatif = "0.17.0-rc.11"
|
||||
int-enum = "0.4"
|
||||
itertools = "0.10"
|
||||
json = "0.12"
|
||||
lazy_static = "1.4"
|
||||
modular-bitfield = "0.11"
|
||||
@@ -28,7 +29,6 @@ proc_macros = { path = "proc_macros" }
|
||||
regex = "1"
|
||||
reqwest = { version = "0.11", features = ["brotli", "deflate", "gzip", "rustls-tls", "socks", "stream"] }
|
||||
RustyXML = "0.3"
|
||||
spin_on = "0.1.1"
|
||||
tokio = { version = "1.19", features = ["rt", "macros", "rt-multi-thread", "time"] }
|
||||
url = "2.2"
|
||||
urlparse = "0.7"
|
||||
|
||||
@@ -2,13 +2,14 @@ use super::downloader::DownloaderInternal;
|
||||
use super::downloader::GetTargetFileName;
|
||||
use super::error::DownloaderError;
|
||||
use crate::ext::io::ClearFile;
|
||||
use crate::ext::replace::ReplaceWith2;
|
||||
use crate::ext::rw_lock::GetRwLock;
|
||||
use crate::ext::try_err::TryErr;
|
||||
use crate::gettext;
|
||||
use futures_util::StreamExt;
|
||||
use http_content_range::ContentRange;
|
||||
use itertools::partition;
|
||||
use reqwest::Response;
|
||||
use spin_on::spin_on;
|
||||
use std::io::Seek;
|
||||
use std::io::SeekFrom;
|
||||
use std::io::Write;
|
||||
@@ -230,35 +231,34 @@ pub async fn check_tasks<
|
||||
let mut need_break = false;
|
||||
let mut dur = None;
|
||||
{
|
||||
let mut tasks = d.tasks.get_mut();
|
||||
tasks.retain_mut(|task| {
|
||||
if task.is_finished() {
|
||||
let re = spin_on(task).unwrap();
|
||||
match re {
|
||||
Ok(_) => {
|
||||
if !d.is_multi_threads() {
|
||||
d.set_downloaded();
|
||||
need_break = true;
|
||||
}
|
||||
let mut tasks = d.tasks.replace_with2(Vec::new());
|
||||
let mut index = partition(&mut tasks, |s| s.is_finished());
|
||||
while index > 0 {
|
||||
let task = tasks.remove(0);
|
||||
let re = task.await.unwrap();
|
||||
match re {
|
||||
Ok(_) => {
|
||||
if !d.is_multi_threads() {
|
||||
d.set_downloaded();
|
||||
need_break = true;
|
||||
}
|
||||
Err(e) => {
|
||||
println!("{}", e);
|
||||
if !d.is_multi_threads() {
|
||||
match d.get_retry_duration() {
|
||||
Some(d) => dur = Some(d),
|
||||
None => {
|
||||
d.set_panic(e);
|
||||
need_break = true;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
println!("{}", e);
|
||||
if !d.is_multi_threads() {
|
||||
match d.get_retry_duration() {
|
||||
Some(d) => dur = Some(d),
|
||||
None => {
|
||||
d.set_panic(e);
|
||||
need_break = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
});
|
||||
index -= 1;
|
||||
}
|
||||
d.tasks.replace_with2(tasks);
|
||||
}
|
||||
if !d.is_multi_threads() && dur.is_some() {
|
||||
let dur = dur.unwrap();
|
||||
|
||||
@@ -11,6 +11,7 @@ extern crate http;
|
||||
extern crate http_content_range;
|
||||
extern crate indicatif;
|
||||
extern crate int_enum;
|
||||
extern crate itertools;
|
||||
extern crate json;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
Reference in New Issue
Block a user