Fixed AI Studio installing a second copy of itself next to an existing installation (#922)
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-08-15 14:04:45 +02:00
1 parent a26c4d93a4
commit 57c0b59fa5
15 files changed
+828 -24

No files matched your search

+48 -10
View File
@@ -23,7 +23,8 @@ use crate::api_token::APIToken;
use crate::clipboard::shutdown_clipboard;
use crate::dotnet::{cleanup_dotnet_server, start_dotnet_server, stop_dotnet_server};
use crate::environment::{
is_prod, is_dev, is_flatpak, CONFIG_DIRECTORY, DATA_DIRECTORY, FLATPAK_LIBRARY_DIRECTORY,
installation_kind, is_prod, is_dev, is_flatpak, InstallationKind, CONFIG_DIRECTORY,
DATA_DIRECTORY, FLATPAK_LIBRARY_DIRECTORY,
};
use crate::log::switch_to_file_logging;
use crate::pdfium::PDFIUM_LIB_PATH;
@@ -514,8 +515,7 @@ pub async fn change_location_to(url: &str) {
/// Checks for updates.
pub async fn check_for_update(_token: APIToken) -> Json<CheckUpdateResponse> {
if !self_update_allowed(is_dev(), is_flatpak()) {
let reason = if is_flatpak() { "Flatpak installations are updated externally" } else { "the app is running in development mode" };
if let Some(reason) = self_update_blocked_reason(is_flatpak(), installation_kind()) {
warn!(Source = "Updater"; "Skipping update check because {reason}.");
return Json(CheckUpdateResponse {
update_is_available: false,
@@ -600,8 +600,7 @@ pub struct CheckUpdateResponse {
/// Installs the update.
pub async fn install_update(_token: APIToken) {
if !self_update_allowed(is_dev(), is_flatpak()) {
let reason = if is_flatpak() { "Flatpak installations are updated externally" } else { "the app is running in development mode" };
if let Some(reason) = self_update_blocked_reason(is_flatpak(), installation_kind()) {
warn!(Source = "Updater"; "Skipping update installation because {reason}.");
return;
}
@@ -660,8 +659,18 @@ pub async fn install_update(_token: APIToken) {
}
}
fn self_update_allowed(development: bool, flatpak: bool) -> bool {
!development && !flatpak
/// Returns why this installation cannot update itself, or `None` when it can.
fn self_update_blocked_reason(flatpak: bool, installation_kind: InstallationKind) -> Option<&'static str> {
if flatpak {
return Some("Flatpak installations are updated externally");
}
match installation_kind {
InstallationKind::User => None,
InstallationKind::Managed => Some("this installation is centrally managed"),
InstallationKind::UnsupportedLocation => Some("this installation is in a location the updater cannot replace"),
InstallationKind::Development => Some("the app is running in development mode"),
}
}
/// Response for application exit requests.
@@ -895,18 +904,47 @@ mod tests {
#[test]
fn self_update_is_disabled_in_development() {
assert!(!self_update_allowed(true, false));
assert!(self_update_blocked_reason(false, InstallationKind::Development).is_some());
}
#[test]
fn self_update_is_disabled_for_flatpak() {
assert!(!self_update_allowed(false, true));
assert!(self_update_blocked_reason(true, InstallationKind::User).is_some());
}
#[test]
fn self_update_is_disabled_for_managed_installations() {
assert!(self_update_blocked_reason(false, InstallationKind::Managed).is_some());
}
#[test]
fn self_update_is_disabled_for_unsupported_installation_locations() {
assert!(self_update_blocked_reason(false, InstallationKind::UnsupportedLocation).is_some());
}
#[test]
fn every_blocked_installation_kind_has_its_own_reason() {
let reasons = [
self_update_blocked_reason(false, InstallationKind::Managed),
self_update_blocked_reason(false, InstallationKind::UnsupportedLocation),
self_update_blocked_reason(false, InstallationKind::Development),
];
for (index, reason) in reasons.iter().enumerate() {
assert!(reason.is_some(), "expected a reason at index {index}");
assert_eq!(
reasons.iter().filter(|other| *other == reason).count(),
1,
"expected the reason at index {index} to be unique"
);
}
}
#[test]
fn self_update_is_enabled_for_normal_production_installations() {
assert!(self_update_allowed(false, false));
assert!(self_update_blocked_reason(false, InstallationKind::User).is_none());
}
#[test]
fn pdfium_library_directory_prefers_resources_libraries() {
let temp_dir = tempfile::tempdir().unwrap();