refactor: get_resource_path, looks in /usr/share
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
parent
42ab70fd07
commit
1576c78d87
|
@ -14,7 +14,8 @@ tasks:
|
|||
- rm -fr dist
|
||||
- linuxdeploy-x86_64.AppImage --appdir dist
|
||||
- cp -v target/release/upend-cli dist/usr/bin/upend
|
||||
- cp -r webui/dist dist/usr/bin/webui
|
||||
- mkdir -p dist/usr/share/upend
|
||||
- cp -r webui/dist dist/usr/share/upend/webui
|
||||
- cp assets/upend.png dist/usr/share/icons/upend.png
|
||||
- linuxdeploy-x86_64.AppImage --appdir dist -d build/upend.desktop --output appimage
|
||||
env:
|
||||
|
|
|
@ -4,13 +4,14 @@ use shadow_rs::{is_debug, shadow};
|
|||
|
||||
shadow!(build);
|
||||
|
||||
pub fn get_static_dir<S: AsRef<str>>(dir: S) -> Result<std::path::PathBuf> {
|
||||
let cwd = std::env::current_exe()?.parent().unwrap().to_path_buf();
|
||||
pub fn get_resource_path<S: AsRef<str>>(dir: S) -> Result<std::path::PathBuf> {
|
||||
let base_path = if is_debug() {
|
||||
cwd.join("../../tmp/static")
|
||||
let cwd = std::env::current_exe()?.parent().unwrap().to_path_buf();
|
||||
cwd.join("../../tmp/resources")
|
||||
} else {
|
||||
cwd
|
||||
"/usr/share/upend".into()
|
||||
};
|
||||
|
||||
let result = base_path.join(dir.as_ref());
|
||||
if result.exists() {
|
||||
Ok(result)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#[macro_use]
|
||||
extern crate upend_db;
|
||||
|
||||
use crate::common::{get_static_dir, REQWEST_ASYNC_CLIENT};
|
||||
use crate::common::{get_resource_path, REQWEST_ASYNC_CLIENT};
|
||||
use crate::config::UpEndConfig;
|
||||
use actix_web::HttpServer;
|
||||
use anyhow::Result;
|
||||
|
@ -347,7 +347,7 @@ async fn main() -> Result<()> {
|
|||
let ui_path = if args.no_ui {
|
||||
None
|
||||
} else {
|
||||
let ui_path = get_static_dir("webui");
|
||||
let ui_path = get_resource_path("webui");
|
||||
if ui_path.is_err() {
|
||||
warn!(
|
||||
"Couldn't locate Web UI directory ({:?}), disabling...",
|
||||
|
|
Loading…
Reference in New Issue