From ef6647bc71a465c21fd0dccff57a015da3e25dfc Mon Sep 17 00:00:00 2001 From: Cory Date: Sat, 31 Jul 2021 10:13:14 -0700 Subject: [PATCH 1/5] Add no-self-update feature --- Cargo.toml | 1 + crates/core/Cargo.toml | 1 + crates/core/src/utility.rs | 12 ++++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b0d3d7e9..37df3000 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ edition = "2018" default = ["wgpu"] wgpu = ["ajour-widgets/wgpu", "iced/wgpu", "iced/default_system_font"] opengl = ["ajour-widgets/opengl", "iced/glow", "iced/glow_default_system_font"] +no-self-update = ["ajour-core/no-self-update"] [dependencies] ajour-core = { version = "1.2.5", path = "crates/core", features=['gui'] } diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 88d35912..7e769bdf 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -11,6 +11,7 @@ edition = "2018" [features] default = [] gui = ['iced_native'] +no-self-update = [] [[bin]] name = "fingerprint_addon" diff --git a/crates/core/src/utility.rs b/crates/core/src/utility.rs index f1de6f2e..543781d6 100644 --- a/crates/core/src/utility.rs +++ b/crates/core/src/utility.rs @@ -2,9 +2,8 @@ use crate::config::{Flavor, SelfUpdateChannel}; use crate::error::DownloadError; #[cfg(target_os = "macos")] use crate::error::FilesystemError; -use crate::network::{download_file, request_async}; +use crate::network::download_file; -use isahc::AsyncReadResponseExt; use regex::Regex; use retry::delay::Fibonacci; use retry::{retry, Error as RetryError, OperationResult}; @@ -58,7 +57,16 @@ pub struct ReleaseAsset { pub download_url: String, } +#[cfg(feature = "no-self-update")] +pub async fn get_latest_release(_channel: SelfUpdateChannel) -> Option { + None +} + +#[cfg(not(feature = "no-self-update"))] pub async fn get_latest_release(channel: SelfUpdateChannel) -> Option { + use crate::network::request_async; + use isahc::AsyncReadResponseExt; + log::debug!("checking for application update"); let mut resp = request_async( From 6d32c26a9ff0e97ce323c9254a2e4c05790dd8e9 Mon Sep 17 00:00:00 2001 From: Cory Date: Sat, 31 Jul 2021 10:13:26 -0700 Subject: [PATCH 2/5] Update makefile --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index b8228b01..dd0521cb 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ DMG_DIR = $(RELEASE_DIR)/osx OPENGL ?= MACOS ?= +NOSELFUPDATE ?= ifdef MACOS ENV :=MACOSX_DEPLOYMENT_TARGET="10.11" @@ -37,6 +38,10 @@ else FEATURE_FLAG := endif +ifdef NOSELFUPDATE + FEATURE_FLAG +=--features no-self-update +endif + vpath $(TARGET) $(RELEASE_DIR) vpath $(APP_NAME) $(APP_DIR) vpath $(DMG_NAME) $(APP_DIR) From e41c859b26bd429342f70b108d85b1d698d6441d Mon Sep 17 00:00:00 2001 From: Cory Date: Sat, 31 Jul 2021 10:13:42 -0700 Subject: [PATCH 3/5] Update release workflow --- .github/workflows/release_to_draft.yml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release_to_draft.yml b/.github/workflows/release_to_draft.yml index 65cd1a25..a455cc95 100644 --- a/.github/workflows/release_to_draft.yml +++ b/.github/workflows/release_to_draft.yml @@ -4,11 +4,10 @@ on: workflow_dispatch: inputs: tag: - description: 'Specify tag to create' + description: "Specify tag to create" required: true jobs: - build: name: Build strategy: @@ -22,6 +21,10 @@ jobs: os: windows-latest make: make binary OPENGL=1 binary_path: target/release/ajour.exe + - target: windows-noselfupdate + os: windows-latest + make: make binary NOSELFUPDATE=1 + binary_path: target/release/ajour.exe - target: linux-wgpu os: ubuntu-16.04 @@ -48,6 +51,10 @@ jobs: os: macos-latest make: make tar OPENGL=1 MACOS=1 binary_path: target/release/ajour.tar.gz + - target: macos-noselfupdate + os: macos-latest + make: make tar MACOS=1 NOSELFUPDATE=1 + binary_path: target/release/ajour.tar.gz runs-on: ${{ matrix.target.os }} @@ -60,7 +67,7 @@ jobs: override: true - name: Do we need linuxdeploy? - if: ${{ matrix.target.os == 'ubuntu-16.04' }} + if: ${{ matrix.target.os == 'ubuntu-16.04' }} run: | wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage chmod +x linuxdeploy-x86_64.AppImage @@ -76,7 +83,7 @@ jobs: - name: Code signing if: ${{ matrix.target.os == 'windows-latest' }} - env: + env: codesign_cert: ${{ secrets.CODESIGN_CERT }} codesign_cert_password: ${{ secrets.CODESIGN_CERT_PASSWORD }} run: | @@ -125,6 +132,10 @@ jobs: artifact_name: ajour.exe asset_name: ajour-opengl.exe asset_type: application/x-dosexec + - artifact: windows-noselfupdate + artifact_name: ajour.exe + asset_name: ajour-noselfupdate.exe + asset_type: application/x-dosexec - artifact: linux-wgpu artifact_name: ajour.AppImage @@ -151,6 +162,10 @@ jobs: artifact_name: ajour.tar.gz asset_name: ajour-opengl-macos.tar.gz asset_type: application/gzip + - artifact: macos-noselfupdate + artifact_name: ajour.tar.gz + asset_name: ajour-noselfupdate-macos.tar.gz + asset_type: application/gzip runs-on: ubuntu-latest env: From acab71de40906bc3674a4794548c656dbbf37d3c Mon Sep 17 00:00:00 2001 From: Cory Date: Sat, 31 Jul 2021 10:18:04 -0700 Subject: [PATCH 4/5] Update CHANGELOG --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6d0596b..1da08a8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,13 @@ and `Removed`. ## [Unreleased] +### Packaging + +- Adds a new cargo feature flag `no-self-update`. When used, Ajour won't check for + newer updates. +- Adds 2 new release assets, one for Windows and Macos, both with this feature + activated. These can be picked up by Chocolatey & Homebrew respectively. + ## [1.2.5] - 2021-07-26 ### Fixed From b212795a09d40df50884e1e87ad5ec3d43bc534d Mon Sep 17 00:00:00 2001 From: Cory Date: Sat, 31 Jul 2021 10:37:39 -0700 Subject: [PATCH 5/5] fix clippy lints --- crates/core/src/addon.rs | 6 ++-- crates/core/src/cache.rs | 2 +- crates/core/src/fs/addon.rs | 7 ++--- crates/core/src/fs/theme.rs | 2 +- crates/core/src/repository/backend/curse.rs | 2 +- crates/core/src/repository/backend/hub.rs | 2 +- crates/core/src/repository/backend/tukui.rs | 2 +- crates/core/src/repository/backend/wowi.rs | 2 +- crates/core/src/utility.rs | 23 +++----------- crates/widgets/src/renderer/table_row.rs | 2 +- src/gui/mod.rs | 2 +- src/gui/update.rs | 34 ++++++++++----------- 12 files changed, 35 insertions(+), 51 deletions(-) diff --git a/crates/core/src/addon.rs b/crates/core/src/addon.rs index bc42a32c..d2b0f92a 100644 --- a/crates/core/src/addon.rs +++ b/crates/core/src/addon.rs @@ -485,7 +485,7 @@ impl Addon { fn is_updatable_by_version_comparison(&self, remote_package: &RemotePackage) -> bool { if let Some(version) = self.version() { let srv = strip_non_digits(&remote_package.version); - let slv = strip_non_digits(&version); + let slv = strip_non_digits(version); return !slv.contains(&srv); } @@ -584,13 +584,13 @@ impl PartialEq for Addon { impl PartialOrd for Addon { fn partial_cmp(&self, other: &Self) -> Option { - Some(self.title().cmp(&other.title())) + Some(self.title().cmp(other.title())) } } impl Ord for Addon { fn cmp(&self, other: &Self) -> Ordering { - self.title().cmp(&other.title()) + self.title().cmp(other.title()) } } diff --git a/crates/core/src/cache.rs b/crates/core/src/cache.rs index 6bc3b352..70748692 100644 --- a/crates/core/src/cache.rs +++ b/crates/core/src/cache.rs @@ -166,7 +166,7 @@ pub async fn remove_addon_entries_with_missing_folders( .iter() .cloned() .enumerate() - .filter(|(_, entry)| !entry.folder_names.iter().all(|f| folder_names.contains(&f))) + .filter(|(_, entry)| !entry.folder_names.iter().all(|f| folder_names.contains(f))) .map(|(idx, _)| idx) .collect::>(); diff --git a/crates/core/src/fs/addon.rs b/crates/core/src/fs/addon.rs index 0d979e26..2b07fa20 100644 --- a/crates/core/src/fs/addon.rs +++ b/crates/core/src/fs/addon.rs @@ -118,10 +118,7 @@ pub async fn install_addon( // Cleanup std::fs::remove_file(&zip_path)?; - let mut addon_folders: Vec<_> = toc_files - .iter() - .filter_map(|p| parse_toc_path(&p)) - .collect(); + let mut addon_folders: Vec<_> = toc_files.iter().filter_map(|p| parse_toc_path(p)).collect(); addon_folders.sort(); // Needed since multi-toc can now insert folder name more than once addon_folders.dedup(); @@ -195,7 +192,7 @@ mod test { files.push(path); } - delete_saved_variables(&folders, &root).unwrap(); + delete_saved_variables(&folders, root).unwrap(); let mut exists = 0; for file in files { diff --git a/crates/core/src/fs/theme.rs b/crates/core/src/fs/theme.rs index f5a89c10..850ce03f 100644 --- a/crates/core/src/fs/theme.rs +++ b/crates/core/src/fs/theme.rs @@ -48,7 +48,7 @@ pub async fn import_theme(url: String) -> Result<(String, Vec), ThemeErro let query = uri.query().ok_or(ThemeError::MissingQuery)?; - let theme = serde_urlencoded::from_str::>(&query)? + let theme = serde_urlencoded::from_str::>(query)? .into_iter() .find(|(name, _)| name == "theme") .map(|(_, theme_json)| serde_json::from_str::(&theme_json)) diff --git a/crates/core/src/repository/backend/curse.rs b/crates/core/src/repository/backend/curse.rs index 242c0269..f34a25e2 100644 --- a/crates/core/src/repository/backend/curse.rs +++ b/crates/core/src/repository/backend/curse.rs @@ -183,7 +183,7 @@ pub(crate) async fn batch_fetch_repo_packages( return Ok(curse_repo_packages); } - let mut curse_packages = curse::fetch_remote_packages_by_ids(&curse_ids).await?; + let mut curse_packages = curse::fetch_remote_packages_by_ids(curse_ids).await?; if let Some(fingerprint_info) = fingerprint_info { // Get repo packages from fingerprint exact matches diff --git a/crates/core/src/repository/backend/hub.rs b/crates/core/src/repository/backend/hub.rs index df8db9dc..bec1ba2f 100644 --- a/crates/core/src/repository/backend/hub.rs +++ b/crates/core/src/repository/backend/hub.rs @@ -93,7 +93,7 @@ pub(crate) async fn batch_fetch_repo_packages( return Ok(hub_repo_packages); } - let hub_packages = hub::fetch_remote_packages(flavor, &hub_ids).await?; + let hub_packages = hub::fetch_remote_packages(flavor, hub_ids).await?; hub_repo_packages.extend( hub_packages diff --git a/crates/core/src/repository/backend/tukui.rs b/crates/core/src/repository/backend/tukui.rs index d27013f1..3d080394 100644 --- a/crates/core/src/repository/backend/tukui.rs +++ b/crates/core/src/repository/backend/tukui.rs @@ -158,7 +158,7 @@ pub(crate) async fn batch_fetch_repo_packages( let fetch_tasks: Vec<_> = tukui_ids .iter() - .map(|id| tukui::fetch_remote_package(&id, &flavor)) + .map(|id| tukui::fetch_remote_package(id, &flavor)) .collect(); tukui_repo_packages.extend( diff --git a/crates/core/src/repository/backend/wowi.rs b/crates/core/src/repository/backend/wowi.rs index c8b287d9..87994d27 100644 --- a/crates/core/src/repository/backend/wowi.rs +++ b/crates/core/src/repository/backend/wowi.rs @@ -97,7 +97,7 @@ pub(crate) async fn batch_fetch_repo_packages( return Ok(wowi_repo_packages); } - let wowi_packages = wowi::fetch_remote_packages(&wowi_ids).await?; + let wowi_packages = wowi::fetch_remote_packages(wowi_ids).await?; wowi_repo_packages.extend( wowi_packages diff --git a/crates/core/src/utility.rs b/crates/core/src/utility.rs index 543781d6..fddc7139 100644 --- a/crates/core/src/utility.rs +++ b/crates/core/src/utility.rs @@ -331,25 +331,12 @@ mod tests { let root_alternate_path = PathBuf::from(r"/Applications/Wow"); let root_path = PathBuf::from(r"/Applications/World of Warcraft"); - assert_eq!( - root_path.eq(&wow_path_resolution(Some(classic_addon_path)).unwrap()), - true - ); - assert_eq!( - root_path.eq(&wow_path_resolution(Some(retail_addon_path)).unwrap()), - true - ); - assert_eq!( - root_path.eq(&wow_path_resolution(Some(retail_interface_path)).unwrap()), - true - ); - assert_eq!( - root_path.eq(&wow_path_resolution(Some(classic_interface_path)).unwrap()), - true - ); - assert_eq!( + assert!(root_path.eq(&wow_path_resolution(Some(classic_addon_path)).unwrap()),); + assert!(root_path.eq(&wow_path_resolution(Some(retail_addon_path)).unwrap()),); + assert!(root_path.eq(&wow_path_resolution(Some(retail_interface_path)).unwrap()),); + assert!(root_path.eq(&wow_path_resolution(Some(classic_interface_path)).unwrap()),); + assert!( root_alternate_path.eq(&wow_path_resolution(Some(classic_alternate_path)).unwrap()), - true ); } diff --git a/crates/widgets/src/renderer/table_row.rs b/crates/widgets/src/renderer/table_row.rs index ffd2ba01..78c0e5f5 100644 --- a/crates/widgets/src/renderer/table_row.rs +++ b/crates/widgets/src/renderer/table_row.rs @@ -31,7 +31,7 @@ where }; let (content, mouse_interaction) = - content.draw(self, &defaults, content_layout, cursor_position, viewport); + content.draw(self, defaults, content_layout, cursor_position, viewport); ( if style.background.is_some() { diff --git a/src/gui/mod.rs b/src/gui/mod.rs index d66d5b2c..ff5412d5 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -2051,10 +2051,10 @@ impl Default for ScaleState { } } +#[allow(clippy::upper_case_acronyms)] #[derive(Debug, Clone)] pub enum BackupFolderKind { AddOns, - #[allow(clippy::upper_case_acronyms)] WTF, Config, Screenshots, diff --git a/src/gui/update.rs b/src/gui/update.rs index a80b9dde..532ab9ff 100644 --- a/src/gui/update.rs +++ b/src/gui/update.rs @@ -2721,7 +2721,7 @@ fn sort_addons( addons.sort_by(|a, b| { a.version() .cmp(&b.version()) - .then_with(|| a.title().cmp(&b.title())) + .then_with(|| a.title().cmp(b.title())) }); } (ColumnKey::LocalVersion, SortDirection::Desc) => { @@ -2729,14 +2729,14 @@ fn sort_addons( a.version() .cmp(&b.version()) .reverse() - .then_with(|| a.title().cmp(&b.title())) + .then_with(|| a.title().cmp(b.title())) }); } (ColumnKey::RemoteVersion, SortDirection::Asc) => { addons.sort_by(|a, b| { a.relevant_release_package(global_release_channel) .cmp(&b.relevant_release_package(global_release_channel)) - .then_with(|| a.cmp(&b)) + .then_with(|| a.cmp(b)) }); } (ColumnKey::RemoteVersion, SortDirection::Desc) => { @@ -2744,14 +2744,14 @@ fn sort_addons( a.relevant_release_package(global_release_channel) .cmp(&b.relevant_release_package(global_release_channel)) .reverse() - .then_with(|| a.cmp(&b)) + .then_with(|| a.cmp(b)) }); } (ColumnKey::Status, SortDirection::Asc) => { - addons.sort_by(|a, b| a.state.cmp(&b.state).then_with(|| a.cmp(&b))); + addons.sort_by(|a, b| a.state.cmp(&b.state).then_with(|| a.cmp(b))); } (ColumnKey::Status, SortDirection::Desc) => { - addons.sort_by(|a, b| a.state.cmp(&b.state).reverse().then_with(|| a.cmp(&b))); + addons.sort_by(|a, b| a.state.cmp(&b.state).reverse().then_with(|| a.cmp(b))); } (ColumnKey::Channel, SortDirection::Asc) => addons.sort_by(|a, b| { a.release_channel @@ -2941,7 +2941,7 @@ fn sort_auras(auras: &mut [Aura], sort_direction: SortDirection, column_key: Aur auras.sort_by(|a, b| { a.installed_symver() .cmp(&b.installed_symver()) - .then_with(|| a.name().cmp(&b.name())) + .then_with(|| a.name().cmp(b.name())) }); } (AuraColumnKey::LocalVersion, SortDirection::Desc) => { @@ -2949,29 +2949,29 @@ fn sort_auras(auras: &mut [Aura], sort_direction: SortDirection, column_key: Aur a.installed_symver() .cmp(&b.installed_symver()) .reverse() - .then_with(|| a.name().cmp(&b.name())) + .then_with(|| a.name().cmp(b.name())) }); } (AuraColumnKey::RemoteVersion, SortDirection::Asc) => { auras.sort_by(|a, b| { a.remote_symver() - .cmp(&b.remote_symver()) - .then_with(|| a.name().cmp(&b.name())) + .cmp(b.remote_symver()) + .then_with(|| a.name().cmp(b.name())) }); } (AuraColumnKey::RemoteVersion, SortDirection::Desc) => { auras.sort_by(|a, b| { a.remote_symver() - .cmp(&b.remote_symver()) + .cmp(b.remote_symver()) .reverse() - .then_with(|| a.name().cmp(&b.name())) + .then_with(|| a.name().cmp(b.name())) }); } (AuraColumnKey::Author, SortDirection::Asc) => { - auras.sort_by(|a, b| a.author().cmp(&b.author())) + auras.sort_by(|a, b| a.author().cmp(b.author())) } (AuraColumnKey::Author, SortDirection::Desc) => { - auras.sort_by(|a, b| a.author().cmp(&b.author()).reverse()) + auras.sort_by(|a, b| a.author().cmp(b.author()).reverse()) } (AuraColumnKey::Type, SortDirection::Asc) => auras.sort_by(|a, b| a.kind().cmp(&b.kind())), (AuraColumnKey::Type, SortDirection::Desc) => { @@ -3018,10 +3018,10 @@ fn query_and_sort_catalog(ajour: &mut Ajour) { .filter_map(|a| { if let Some(query) = &query { let title_score = fuzzy_matcher - .fuzzy_match(&a.name, &query) + .fuzzy_match(&a.name, query) .unwrap_or_default(); let description_score = fuzzy_matcher - .fuzzy_match(&a.summary, &query) + .fuzzy_match(&a.summary, query) .unwrap_or_default() / 2; @@ -3051,7 +3051,7 @@ fn query_and_sort_catalog(ajour: &mut Ajour) { let mut catalog_rows = if query.is_some() { // If a query is defined, the default sort is the fuzzy match score catalog_rows_and_score.sort_by(|(addon_a, score_a), (addon_b, score_b)| { - score_a.cmp(&score_b).reverse().then_with(|| { + score_a.cmp(score_b).reverse().then_with(|| { addon_a .addon .number_of_downloads