feat(updater): remove AtomGit download source
This commit is contained in:
1 parent
72d05ac3ec
commit
4cc14f5f72
26 files changed
+44
-755
No files matched your search
@@ -15,7 +15,6 @@ const OFFICIAL_UPDATE_ENDPOINTS: [&str; 2] = [
|
||||
const R2_LATEST_RELEASE_DOWNLOAD_PREFIX: &str = "https://dl.dbxio.com/releases/latest/";
|
||||
const CNB_RELEASE_DOWNLOAD_PREFIX: &str = "https://cnb.cool/dbxio.com/dbx/-/releases/download/";
|
||||
const GITHUB_RELEASE_DOWNLOAD_PREFIX: &str = "https://github.com/t8y2/dbx/releases/download/";
|
||||
const ATOMGIT_RELEASE_DOWNLOAD_PREFIX: &str = "https://atomgit.com/t8y2/dbx/releases/download/";
|
||||
const UPDATE_DOWNLOAD_PROGRESS_EVENT: &str = "update-download-progress";
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -23,7 +22,6 @@ const UPDATE_DOWNLOAD_PROGRESS_EVENT: &str = "update-download-progress";
|
||||
pub enum UpdateDownloadSource {
|
||||
Official,
|
||||
Cnb,
|
||||
Atomgit,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
@@ -37,7 +35,6 @@ impl UpdateDownloadSource {
|
||||
match self {
|
||||
Self::Official => "official",
|
||||
Self::Cnb => "cnb",
|
||||
Self::Atomgit => "atomgit",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,14 +49,6 @@ impl UpdateDownloadSource {
|
||||
OFFICIAL_UPDATE_ENDPOINTS[0].to_string(),
|
||||
])
|
||||
}
|
||||
Self::Atomgit => {
|
||||
let version =
|
||||
latest_version.ok_or_else(|| "Latest version is required for AtomGit updates.".to_string())?;
|
||||
Ok(vec![
|
||||
format!("{ATOMGIT_RELEASE_DOWNLOAD_PREFIX}{}/latest.json", tag_version(version)),
|
||||
OFFICIAL_UPDATE_ENDPOINTS[0].to_string(),
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +70,6 @@ impl UpdateDownloadSource {
|
||||
fn mirror_download_prefix(&self) -> Option<&'static str> {
|
||||
match self {
|
||||
Self::Cnb => Some(CNB_RELEASE_DOWNLOAD_PREFIX),
|
||||
Self::Atomgit => Some(ATOMGIT_RELEASE_DOWNLOAD_PREFIX),
|
||||
Self::Official => None,
|
||||
}
|
||||
}
|
||||
@@ -207,8 +195,8 @@ async fn update_url_is_available(url: &str) -> bool {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{
|
||||
tag_version, UpdateDownloadSource, ATOMGIT_RELEASE_DOWNLOAD_PREFIX, CNB_RELEASE_DOWNLOAD_PREFIX,
|
||||
OFFICIAL_UPDATE_ENDPOINTS, R2_LATEST_RELEASE_DOWNLOAD_PREFIX,
|
||||
tag_version, UpdateDownloadSource, CNB_RELEASE_DOWNLOAD_PREFIX, OFFICIAL_UPDATE_ENDPOINTS,
|
||||
R2_LATEST_RELEASE_DOWNLOAD_PREFIX,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -232,18 +220,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builds_atomgit_update_endpoint_for_tag() {
|
||||
let endpoints = UpdateDownloadSource::Atomgit.endpoints(Some("0.5.44")).unwrap();
|
||||
assert_eq!(
|
||||
endpoints,
|
||||
vec![
|
||||
format!("{ATOMGIT_RELEASE_DOWNLOAD_PREFIX}v0.5.44/latest.json"),
|
||||
OFFICIAL_UPDATE_ENDPOINTS[0].to_string(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rewrites_github_asset_url_to_cnb() {
|
||||
let download_url = UpdateDownloadSource::Cnb
|
||||
@@ -261,27 +237,10 @@ mod tests {
|
||||
assert_eq!(download_url, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rewrites_github_asset_url_to_atomgit() {
|
||||
let download_url = UpdateDownloadSource::Atomgit
|
||||
.rewrite_download_url("https://github.com/t8y2/dbx/releases/download/v0.5.44/DBX_0.5.44_x64.dmg")
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(download_url, "https://atomgit.com/t8y2/dbx/releases/download/v0.5.44/DBX_0.5.44_x64.dmg");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn accepts_existing_atomgit_asset_url() {
|
||||
let download_url = UpdateDownloadSource::Atomgit
|
||||
.rewrite_download_url("https://atomgit.com/t8y2/dbx/releases/download/v0.5.44/DBX_0.5.44_x64.dmg")
|
||||
.unwrap();
|
||||
assert_eq!(download_url, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builds_r2_fallback_for_mirror_asset() {
|
||||
let fallback = UpdateDownloadSource::Atomgit
|
||||
.r2_fallback_url("https://atomgit.com/t8y2/dbx/releases/download/v0.5.44/DBX_0.5.44_x64.dmg")
|
||||
let fallback = UpdateDownloadSource::Cnb
|
||||
.r2_fallback_url("https://cnb.cool/dbxio.com/dbx/-/releases/download/v0.5.44/DBX_0.5.44_x64.dmg")
|
||||
.unwrap();
|
||||
assert_eq!(fallback, Some(format!("{R2_LATEST_RELEASE_DOWNLOAD_PREFIX}DBX_0.5.44_x64.dmg")));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user