mirror of https://github.com/lapce/lapce.git
fix: differentiate between stable/nightly/debug
This commit is contained in:
parent
255310e3e0
commit
796cd3bca6
|
@ -310,9 +310,17 @@ fn start_remote(&self, remote: impl Remote) -> Result<()> {
|
|||
// ! Below paths have to be synced with what is
|
||||
// ! returned by Config::proxy_directory()
|
||||
let remote_proxy_path = match platform {
|
||||
Windows => format!("%HOMEDRIVE%%HOMEPATH%\\AppData\\Local\\lapce\\{APPLICATION_NAME}\\data\\proxy"),
|
||||
Darwin => format!("~/Library/Application Support/dev.lapce.{APPLICATION_NAME}/proxy"),
|
||||
_ => format!("~/.local/share/{APPLICATION_NAME}/proxy").to_lowercase(),
|
||||
Windows => format!(
|
||||
"%HOMEDRIVE%%HOMEPATH%\\AppData\\Local\\lapce\\{}\\data\\proxy",
|
||||
*APPLICATION_NAME
|
||||
),
|
||||
Darwin => format!(
|
||||
"~/Library/Application Support/dev.lapce.{}/proxy",
|
||||
*APPLICATION_NAME
|
||||
),
|
||||
_ => {
|
||||
format!("~/.local/share/{}/proxy", *APPLICATION_NAME).to_lowercase()
|
||||
}
|
||||
};
|
||||
|
||||
let remote_proxy_file = match platform {
|
||||
|
@ -342,7 +350,11 @@ fn start_remote(&self, remote: impl Remote) -> Result<()> {
|
|||
.ok_or_else(|| anyhow!("can't find proxy directory"))?
|
||||
.join(&proxy_filename);
|
||||
if !local_proxy_file.exists() {
|
||||
let url = format!("https://github.com/lapce/lapce/releases/download/{}/{proxy_filename}.gz", if VERSION.eq("nightly") { VERSION.to_string() } else { format!("v{}", *VERSION) });
|
||||
let url = format!("https://github.com/lapce/lapce/releases/download/{}/{proxy_filename}.gz", match *VERSION {
|
||||
"nightly" | "debug" => "nightly".to_string(),
|
||||
_ => format!("v{}", *VERSION),
|
||||
});
|
||||
log::debug!(target: "lapce_data::proxy::start_remote", "proxy download URI: {url}");
|
||||
let mut resp = reqwest::blocking::get(url).expect("request failed");
|
||||
if resp.status().is_success() {
|
||||
let mut out = std::fs::File::create(&local_proxy_file)
|
||||
|
|
|
@ -7,12 +7,16 @@
|
|||
pub struct Directory {}
|
||||
|
||||
impl Directory {
|
||||
fn project_dirs() -> Option<ProjectDirs> {
|
||||
ProjectDirs::from("dev", "lapce", *APPLICATION_NAME)
|
||||
}
|
||||
|
||||
// Get path of local data directory
|
||||
// Local data directory differs from data directory
|
||||
// on some platforms and is not transferred across
|
||||
// machines
|
||||
pub fn data_local_directory() -> Option<PathBuf> {
|
||||
match ProjectDirs::from("dev", "lapce", APPLICATION_NAME) {
|
||||
match Self::project_dirs() {
|
||||
Some(dir) => {
|
||||
let dir = dir.data_local_dir();
|
||||
if !dir.exists() {
|
||||
|
@ -89,7 +93,7 @@ pub fn plugins_directory() -> Option<PathBuf> {
|
|||
|
||||
// Config directory contain only configuration files
|
||||
pub fn config_directory() -> Option<PathBuf> {
|
||||
match ProjectDirs::from("dev", "lapce", APPLICATION_NAME) {
|
||||
match Self::project_dirs() {
|
||||
Some(dir) => {
|
||||
let dir = dir.config_dir();
|
||||
if !dir.exists() {
|
||||
|
|
|
@ -20,21 +20,29 @@
|
|||
};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub const APPLICATION_NAME: &str = "Lapce-debug";
|
||||
pub static APPLICATION_NAME: Lazy<&str> = Lazy::new(application_name);
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub const APPLICATION_NAME: &str = "Lapce";
|
||||
fn application_name() -> &'static str {
|
||||
if cfg!(debug_assertions) {
|
||||
"Lapce-Debug"
|
||||
} else if option_env!("RELEASE_TAG_NAME")
|
||||
.unwrap_or("")
|
||||
.starts_with("nightly")
|
||||
{
|
||||
"Lapce-Nightly"
|
||||
} else {
|
||||
"Lapce-Stable"
|
||||
}
|
||||
}
|
||||
|
||||
pub static VERSION: Lazy<&str> = Lazy::new(version);
|
||||
|
||||
fn version() -> &'static str {
|
||||
if cfg!(debug_assertions) {
|
||||
"debug"
|
||||
} else if option_env!("RELEASE_TAG_NAME").is_some()
|
||||
&& option_env!("RELEASE_TAG_NAME")
|
||||
.unwrap()
|
||||
.starts_with("nightly")
|
||||
} else if option_env!("RELEASE_TAG_NAME")
|
||||
.unwrap_or("")
|
||||
.starts_with("nightly")
|
||||
{
|
||||
option_env!("RELEASE_TAG_NAME").unwrap()
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue