mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
appmgr: reqwest compatibility
This commit is contained in:
committed by
Keagan McClelland
parent
3fce90b7a8
commit
48f6543cb9
@@ -16,7 +16,7 @@ use futures::stream::StreamExt;
|
||||
use futures::stream::TryStreamExt;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio::io::{AsyncRead, ReadBuf};
|
||||
use tokio_compat_02::IoCompat;
|
||||
use tokio_compat_02::{FutureExt, IoCompat};
|
||||
use tokio_tar as tar;
|
||||
|
||||
use crate::config::{ConfigRuleEntry, ConfigSpec};
|
||||
@@ -99,6 +99,7 @@ pub async fn download(url: &str, name: Option<&str>) -> Result<PathBuf, crate::E
|
||||
let url = reqwest::Url::parse(url).no_code()?;
|
||||
log::info!("Downloading {}.", url.as_str());
|
||||
let response = reqwest::get(url)
|
||||
.compat()
|
||||
.await
|
||||
.with_code(crate::error::NETWORK_ERROR)?
|
||||
.error_for_status()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use emver::VersionRange;
|
||||
use tokio_compat_02::FutureExt;
|
||||
|
||||
use crate::apps::AppConfig;
|
||||
use crate::manifest::ManifestLatest;
|
||||
@@ -12,6 +13,7 @@ pub async fn manifest(id: &str, version: &VersionRange) -> Result<ManifestLatest
|
||||
id,
|
||||
version
|
||||
))
|
||||
.compat()
|
||||
.await
|
||||
.with_code(crate::error::NETWORK_ERROR)?
|
||||
.error_for_status()
|
||||
@@ -34,6 +36,7 @@ pub async fn version(id: &str, version: &VersionRange) -> Result<emver::Version,
|
||||
id,
|
||||
version
|
||||
))
|
||||
.compat()
|
||||
.await
|
||||
.with_code(crate::error::NETWORK_ERROR)?
|
||||
.error_for_status()
|
||||
@@ -51,6 +54,7 @@ pub async fn config(id: &str, version: &VersionRange) -> Result<AppConfig, Error
|
||||
id,
|
||||
version
|
||||
))
|
||||
.compat()
|
||||
.await
|
||||
.with_code(crate::error::NETWORK_ERROR)?
|
||||
.error_for_status()
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::cmp::Ordering;
|
||||
use async_trait::async_trait;
|
||||
use failure::ResultExt as _;
|
||||
use futures::stream::TryStreamExt;
|
||||
use tokio_compat_02::FutureExt;
|
||||
|
||||
use crate::util::{to_yaml_async_writer, AsyncCompat, PersistencePath};
|
||||
use crate::Error;
|
||||
@@ -168,7 +169,7 @@ pub async fn self_update(requirement: emver::VersionRange) -> Result<(), Error>
|
||||
.collect();
|
||||
let url = format!("{}/appmgr?spec={}", &*crate::SYS_REGISTRY_URL, req_str);
|
||||
log::info!("Fetching new version from {}", url);
|
||||
let response = reqwest::get(&url)
|
||||
let response = reqwest::get(&url).compat()
|
||||
.await
|
||||
.with_code(crate::error::NETWORK_ERROR)?
|
||||
.error_for_status()
|
||||
|
||||
@@ -25,6 +25,7 @@ impl VersionT for Version {
|
||||
tokio::io::copy(
|
||||
&mut AsyncCompat(
|
||||
reqwest::get(&format!("{}/torrc?spec==0.0.0", &*crate::SYS_REGISTRY_URL))
|
||||
.compat()
|
||||
.await
|
||||
.with_context(|e| format!("GET {}/torrc: {}", &*crate::SYS_REGISTRY_URL, e))
|
||||
.with_code(crate::error::NETWORK_ERROR)?
|
||||
|
||||
@@ -22,6 +22,7 @@ impl VersionT for Version {
|
||||
tokio::io::copy(
|
||||
&mut AsyncCompat(
|
||||
reqwest::get(&format!("{}/torrc?spec==0.1.1", &*crate::SYS_REGISTRY_URL))
|
||||
.compat()
|
||||
.await
|
||||
.with_context(|e| format!("GET {}/torrc: {}", &*crate::SYS_REGISTRY_URL, e))
|
||||
.with_code(crate::error::NETWORK_ERROR)?
|
||||
@@ -76,6 +77,7 @@ impl VersionT for Version {
|
||||
tokio::io::copy(
|
||||
&mut AsyncCompat(
|
||||
reqwest::get(&format!("{}/torrc?spec==0.1.0", &*crate::SYS_REGISTRY_URL))
|
||||
.compat()
|
||||
.await
|
||||
.with_context(|e| format!("GET {}/torrc: {}", &*crate::SYS_REGISTRY_URL, e))
|
||||
.no_code()?
|
||||
|
||||
Reference in New Issue
Block a user