mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-07-07 08:46:26 +00:00
Added Flatpak PDFium library lookup (#834)
Some checks are pending
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (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
Some checks are pending
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (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:
parent
a1d2ff32fc
commit
590b1e4021
@ -5,6 +5,7 @@
|
||||
- Added support for organization-approved assistant plugins, so trusted assistant plugins can be enabled without requiring each user to run a separate security audit.
|
||||
- Added support for assistant plugin tiles that can open a chat directly in a chosen workspace.
|
||||
- Improved the provider selection by showing small capability icons for supported audio, image, speech, and reasoning features of the selected model.
|
||||
- Improved PDF file handling in Flatpak builds by supporting the standard Flatpak library location for PDFium and adding clearer diagnostics for troubleshooting PDF loading.
|
||||
- Improved source links in chat answers when file or document names contained spaces, umlauts, or other special characters. Source entries now open much more reliably for documents with names such as PDFs from shared portals or internal knowledge bases.
|
||||
- Improved all assistants, so running tasks can continue when you leave the assistant and return later.
|
||||
- Improved the assistant overview so it shows which assistants are still running or have a result ready.
|
||||
|
||||
@ -24,7 +24,9 @@ use tokio::sync::broadcast;
|
||||
use tokio::time;
|
||||
use crate::api_token::APIToken;
|
||||
use crate::dotnet::{cleanup_dotnet_server, start_dotnet_server, stop_dotnet_server};
|
||||
use crate::environment::{is_prod, is_dev, CONFIG_DIRECTORY, DATA_DIRECTORY};
|
||||
use crate::environment::{
|
||||
is_prod, is_dev, is_flatpak, CONFIG_DIRECTORY, DATA_DIRECTORY, FLATPAK_LIBRARY_DIRECTORY,
|
||||
};
|
||||
use crate::log::switch_to_file_logging;
|
||||
use crate::pdfium::PDFIUM_LIB_PATH;
|
||||
use crate::qdrant_edge_database::{start_qdrant_edge_database, stop_qdrant_edge_database};
|
||||
@ -974,7 +976,7 @@ fn set_pdfium_path<R: tauri::Runtime>(path_resolver: &PathResolver<R>) {
|
||||
}
|
||||
};
|
||||
|
||||
match select_pdfium_library_directory(&resource_dir) {
|
||||
match select_pdfium_library_directory(&resource_dir, is_flatpak()) {
|
||||
Some(path) => {
|
||||
*PDFIUM_LIB_PATH.lock().unwrap() = Some(path.to_string_lossy().to_string());
|
||||
}
|
||||
@ -984,11 +986,23 @@ fn set_pdfium_path<R: tauri::Runtime>(path_resolver: &PathResolver<R>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn select_pdfium_library_directory(resource_dir: &Path) -> Option<PathBuf> {
|
||||
let candidate_paths = [
|
||||
resource_dir.join("resources").join("libraries"),
|
||||
resource_dir.join("libraries"),
|
||||
];
|
||||
fn select_pdfium_library_directory(resource_dir: &Path, include_flatpak_library_directory: bool) -> Option<PathBuf> {
|
||||
select_pdfium_library_directory_for(resource_dir, include_flatpak_library_directory, Path::new(FLATPAK_LIBRARY_DIRECTORY))
|
||||
}
|
||||
|
||||
fn select_pdfium_library_directory_for(
|
||||
resource_dir: &Path,
|
||||
include_flatpak_library_directory: bool,
|
||||
flatpak_library_directory: &Path,
|
||||
) -> Option<PathBuf> {
|
||||
let mut candidate_paths = Vec::new();
|
||||
|
||||
if include_flatpak_library_directory {
|
||||
candidate_paths.push(flatpak_library_directory.to_path_buf());
|
||||
}
|
||||
|
||||
candidate_paths.push(resource_dir.join("resources").join("libraries"));
|
||||
candidate_paths.push(resource_dir.join("libraries"));
|
||||
|
||||
for path in candidate_paths {
|
||||
let pdfium_library_path = Pdfium::pdfium_platform_library_name_at_path(&path);
|
||||
@ -1022,7 +1036,7 @@ mod tests {
|
||||
create_pdfium_library_in(&libraries);
|
||||
|
||||
assert_eq!(
|
||||
select_pdfium_library_directory(temp_dir.path()),
|
||||
select_pdfium_library_directory(temp_dir.path(), false),
|
||||
Some(resources_libraries)
|
||||
);
|
||||
}
|
||||
@ -1036,7 +1050,7 @@ mod tests {
|
||||
create_pdfium_library_in(&libraries);
|
||||
|
||||
assert_eq!(
|
||||
select_pdfium_library_directory(temp_dir.path()),
|
||||
select_pdfium_library_directory(temp_dir.path(), false),
|
||||
Some(libraries)
|
||||
);
|
||||
}
|
||||
@ -1047,7 +1061,33 @@ mod tests {
|
||||
fs::create_dir_all(temp_dir.path().join("resources").join("libraries")).unwrap();
|
||||
fs::create_dir_all(temp_dir.path().join("libraries")).unwrap();
|
||||
|
||||
assert_eq!(select_pdfium_library_directory(temp_dir.path()), None);
|
||||
assert_eq!(select_pdfium_library_directory(temp_dir.path(), false), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdfium_library_directory_prefers_flatpak_library_directory_when_flatpak() {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
let flatpak_library_directory = temp_dir.path().join("app").join("lib");
|
||||
let resources_libraries = temp_dir.path().join("resources").join("libraries");
|
||||
create_pdfium_library_in(&flatpak_library_directory);
|
||||
create_pdfium_library_in(&resources_libraries);
|
||||
|
||||
assert_eq!(
|
||||
select_pdfium_library_directory_for(temp_dir.path(), true, &flatpak_library_directory),
|
||||
Some(flatpak_library_directory)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdfium_library_directory_skips_flatpak_library_directory_when_not_flatpak() {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
let flatpak_library_directory = temp_dir.path().join("app").join("lib");
|
||||
create_pdfium_library_in(&flatpak_library_directory);
|
||||
|
||||
assert_eq!(
|
||||
select_pdfium_library_directory_for(temp_dir.path(), false, &flatpak_library_directory),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
fn create_pdfium_library_in(path: &Path) {
|
||||
|
||||
@ -31,6 +31,8 @@ pub const DOTNET_ENV_CUSTOM_ROOT_CERTIFICATE_ALLOWED_HOSTS: &str = "AI_STUDIO_EX
|
||||
#[cfg(any(target_os = "linux", test))]
|
||||
const FLATPAK_ENTERPRISE_POLICY_DIRECTORY: &str = "/app/etc/MindWorkAI";
|
||||
|
||||
pub(crate) const FLATPAK_LIBRARY_DIRECTORY: &str = "/app/lib";
|
||||
|
||||
const ENTERPRISE_ENV_CONFIG_ID_PREFIX: &str = "MINDWORK_AI_STUDIO_ENTERPRISE_CONFIG_ID";
|
||||
const ENTERPRISE_ENV_CONFIG_SERVER_URL_PREFIX: &str = "MINDWORK_AI_STUDIO_ENTERPRISE_CONFIG_SERVER_URL";
|
||||
const ENTERPRISE_ENV_CONFIGS: &str = "MINDWORK_AI_STUDIO_ENTERPRISE_CONFIGS";
|
||||
|
||||
@ -2,7 +2,7 @@ use std::error::Error;
|
||||
use std::sync::Mutex;
|
||||
use once_cell::sync::Lazy;
|
||||
use pdfium_render::prelude::Pdfium;
|
||||
use log::{error, warn};
|
||||
use log::{error, info, warn};
|
||||
|
||||
pub static PDFIUM_LIB_PATH: Lazy<Mutex<Option<String>>> = Lazy::new(|| Mutex::new(None));
|
||||
static PDFIUM: Lazy<Mutex<Option<Pdfium>>> = Lazy::new(|| Mutex::new(None));
|
||||
@ -32,11 +32,22 @@ impl PdfiumInit for Pdfium {
|
||||
fn load_pdfium() -> Result<Pdfium, String> {
|
||||
let lib_path = PDFIUM_LIB_PATH.lock().unwrap().clone();
|
||||
if let Some(path) = lib_path.as_ref() {
|
||||
return match Pdfium::bind_to_library(Pdfium::pdfium_platform_library_name_at_path(path)) {
|
||||
Ok(binding) => Ok(Pdfium::new(binding)),
|
||||
let pdfium_library_path = Pdfium::pdfium_platform_library_name_at_path(path);
|
||||
|
||||
return match Pdfium::bind_to_library(&pdfium_library_path) {
|
||||
Ok(binding) => {
|
||||
info!("Loaded PDFium from '{path}'.", path = pdfium_library_path.to_string_lossy());
|
||||
Ok(Pdfium::new(binding))
|
||||
},
|
||||
Err(library_error) => {
|
||||
match Pdfium::bind_to_system_library() {
|
||||
Ok(binding) => Ok(Pdfium::new(binding)),
|
||||
Ok(binding) => {
|
||||
info!(
|
||||
"Loaded PDFium from the system library after failing to load '{path}'.",
|
||||
path = pdfium_library_path.to_string_lossy(),
|
||||
);
|
||||
Ok(Pdfium::new(binding))
|
||||
},
|
||||
Err(system_error) => {
|
||||
let error_message = format!(
|
||||
"Failed to load PDFium from '{path}' and the system library. Developer action (from repo root): run the build script once to download the required PDFium version: `cd app/Build` and `dotnet run build`. Details: library error: '{library_error}'; system error: '{system_error}'."
|
||||
@ -52,7 +63,10 @@ fn load_pdfium() -> Result<Pdfium, String> {
|
||||
|
||||
warn!("No custom PDFium library path set; trying to load PDFium from the system library.");
|
||||
match Pdfium::bind_to_system_library() {
|
||||
Ok(binding) => Ok(Pdfium::new(binding)),
|
||||
Ok(binding) => {
|
||||
info!("Loaded PDFium from the system library.");
|
||||
Ok(Pdfium::new(binding))
|
||||
},
|
||||
Err(system_error) => {
|
||||
let error_message = format!(
|
||||
"Failed to load PDFium from the system library. Developer action (from repo root): run the build script once to download the required PDFium version: `cd app/Build` and `dotnet run build`. Details: '{system_error}'."
|
||||
|
||||
Loading…
Reference in New Issue
Block a user