Add support to disable strategies via crate Cargo.toml

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2024-07-22 23:54:50 +10:00
parent ac19952110
commit f7643e1da1
No known key found for this signature in database
GPG key ID: 76D1E687CA3C4928
6 changed files with 36 additions and 2 deletions

View file

@ -1,6 +1,7 @@
use std::{borrow::Cow, fmt, iter, path::Path, sync::Arc};
use binstalk_git_repo_api::gh_api_client::{GhApiError, GhReleaseArtifact, GhReleaseArtifactUrl};
use binstalk_types::cargo_toml_binstall::Strategy;
use compact_str::{CompactString, ToCompactString};
use either::Either;
use leon::Template;
@ -396,6 +397,10 @@ impl super::Fetcher for GhCrateMeta {
FETCHER_GH_CRATE_META
}
fn strategy(&self) -> Strategy {
Strategy::CrateMetaData
}
fn is_third_party(&self) -> bool {
false
}

View file

@ -4,7 +4,7 @@ use std::{path::Path, sync::Arc, time::Duration};
use binstalk_downloader::{download::DownloadError, remote::Error as RemoteError};
use binstalk_git_repo_api::gh_api_client::{GhApiError, GhRepo, RepoInfo as GhRepoInfo};
use binstalk_types::cargo_toml_binstall::SigningAlgorithm;
use binstalk_types::cargo_toml_binstall::{SigningAlgorithm, Strategy};
use thiserror::Error as ThisError;
use tokio::{sync::OnceCell, task::JoinError, time::sleep};
pub use url::ParseError as UrlParseError;
@ -134,6 +134,9 @@ pub trait Fetcher: Send + Sync {
/// [`Fetcher::fetch_and_extract`].
fn fetcher_name(&self) -> &'static str;
/// The strategy used by this fetcher
fn strategy(&self) -> Strategy;
/// Should return true if the remote is from a third-party source
fn is_third_party(&self) -> bool;

View file

@ -5,7 +5,7 @@ use std::{
};
use binstalk_downloader::remote::Method;
use binstalk_types::cargo_toml_binstall::{PkgFmt, PkgMeta, PkgSigning};
use binstalk_types::cargo_toml_binstall::{PkgFmt, PkgMeta, PkgSigning, Strategy};
use tokio::sync::OnceCell;
use tracing::{error, info, trace};
use url::Url;
@ -252,6 +252,10 @@ by rust officially."#,
"QuickInstall"
}
fn strategy(&self) -> Strategy {
Strategy::QuickInstall
}
fn is_third_party(&self) -> bool {
true
}