This repository was archived by the owner on Sep 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 87
add support for townlong-yak addons #529
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ use chrono::prelude::*; | |
use isahc::ResponseExt; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
const CATALOG_URL: &str = "https://github.com/ajour/ajour-catalog/raw/master/catalog.json"; | ||
const CATALOG_URL: &str = "https://raw.githubusercontent.com/ajour/ajour-catalog/3ce1414498adbc7167f11fe0dac7cd58e7b55391/catalog.json"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure we change this back before merging. I switched over to test. |
||
|
||
type Etag = Option<String>; | ||
|
||
|
@@ -65,6 +65,8 @@ pub enum Source { | |
Tukui, | ||
#[serde(alias = "wowi")] | ||
WowI, | ||
#[serde(alias = "townlong-yak")] | ||
TownlongYak, | ||
} | ||
|
||
impl std::fmt::Display for Source { | ||
|
@@ -73,6 +75,7 @@ impl std::fmt::Display for Source { | |
Source::Curse => "Curse", | ||
Source::Tukui => "Tukui", | ||
Source::WowI => "WowInterface", | ||
Source::TownlongYak => "TownlongYak", | ||
}; | ||
write!(f, "{}", s) | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
use crate::{ | ||
addon::{Addon, AddonFolder, AddonState}, | ||
cache::{self, AddonCache, AddonCacheEntry, FingerprintCache}, | ||
cache::{self, AddonCache, AddonCacheEntry, ExternalReleaseId, FingerprintCache}, | ||
config::Flavor, | ||
error::{CacheError, DownloadError, ParseError, RepositoryError}, | ||
fs::PersistentData, | ||
murmur2::calculate_hash, | ||
repository::{curse, tukui, wowi, RepositoryIdentifiers, RepositoryKind, RepositoryPackage}, | ||
repository::{ | ||
curse, townlongyak, tukui, wowi, RepositoryIdentifiers, RepositoryKind, RepositoryPackage, | ||
}, | ||
}; | ||
use async_std::sync::{Arc, Mutex}; | ||
use fancy_regex::Regex; | ||
|
@@ -433,6 +435,7 @@ async fn get_all_repo_packages( | |
let mut curse_ids = vec![]; | ||
let mut tukui_ids = vec![]; | ||
let mut wowi_ids = vec![]; | ||
let mut townlong_ids = vec![]; | ||
let mut git_urls = vec![]; | ||
|
||
let cached_folder_names: Vec<_> = cache_entries | ||
|
@@ -494,6 +497,17 @@ async fn get_all_repo_packages( | |
wowi_ids.dedup(); | ||
} | ||
|
||
// Get all possible townlong_ids (hub) ids | ||
{ | ||
townlong_ids.extend( | ||
cache_entries | ||
.iter() | ||
.filter(|e| e.repository == RepositoryKind::TownlongYak) | ||
.map(|e| e.repository_id.clone()), | ||
); | ||
townlong_ids.dedup(); | ||
} | ||
|
||
// Get all possible git urls | ||
{ | ||
git_urls.extend( | ||
|
@@ -624,6 +638,34 @@ async fn get_all_repo_packages( | |
wowi_repo_packages.len() | ||
); | ||
|
||
// Get all townlong repo packages | ||
let townlong_repo_packages = if !townlong_ids.is_empty() { | ||
let townlong_packages = townlongyak::fetch_remote_packages(flavor, &townlong_ids).await?; | ||
|
||
townlong_packages | ||
.into_iter() | ||
.map(|package| { | ||
( | ||
package.id.to_string(), | ||
townlongyak::metadata_from_townlong_package(flavor, package), | ||
) | ||
}) | ||
.filter_map(|(id, metadata)| { | ||
RepositoryPackage::from_repo_id(flavor, RepositoryKind::TownlongYak, id) | ||
.ok() | ||
.map(|r| r.with_metadata(metadata)) | ||
}) | ||
.collect::<Vec<_>>() | ||
} else { | ||
vec![] | ||
}; | ||
|
||
log::debug!( | ||
"{} - {} townlong packages fetched", | ||
flavor, | ||
townlong_repo_packages.len() | ||
); | ||
|
||
// Get all git repo packages | ||
let git_repo_packages = if !git_urls.is_empty() { | ||
let fetch_tasks = git_urls | ||
|
@@ -670,6 +712,7 @@ async fn get_all_repo_packages( | |
&curse_repo_packages[..], | ||
&tukui_repo_packages[..], | ||
&wowi_repo_packages[..], | ||
&townlong_repo_packages[..], | ||
&git_repo_packages[..], | ||
] | ||
.concat()) | ||
|
@@ -688,7 +731,20 @@ fn build_addons( | |
let repo_idx = repo_packages | ||
.iter() | ||
.position(|r| r.id == e.repository_id && r.kind == e.repository)?; | ||
let repo_package = repo_packages.remove(repo_idx); | ||
|
||
let mut repo_package = repo_packages.remove(repo_idx); | ||
|
||
// Set the file id / version from the cache entry. This is needed to properly | ||
// validate the installed version against the remote version | ||
match &e.external_release_id { | ||
Some(ExternalReleaseId::FileId(file_id)) => { | ||
repo_package.metadata.file_id = Some(*file_id) | ||
} | ||
Some(ExternalReleaseId::Version(version)) => { | ||
repo_package.metadata.version = Some(version.clone()) | ||
} | ||
None => {} | ||
} | ||
Comment on lines
+737
to
+747
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is where we apply that cached remote release version when building addon from cache entry |
||
|
||
// Get and remove all matching addon folders | ||
let folder_idxs: Vec<_> = addon_folders | ||
|
@@ -832,6 +888,15 @@ fn build_addons( | |
.count() | ||
); | ||
|
||
log::debug!( | ||
"{} - {} addons built from townlong-yak packages", | ||
flavor, | ||
concatenated_addons | ||
.iter() | ||
.filter(|a| a.repository_kind() == Some(RepositoryKind::TownlongYak)) | ||
.count() | ||
); | ||
|
||
log::debug!( | ||
"{} - {} addons built from git packages", | ||
flavor, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how we cache the version that was just installed / updated. When we reload the addon from the cache, it'll use this as the version / file_id to check against the remote API. This resolves issues where the addon .toc version is not comparable to the remote version on the API