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
|
// ! Below paths have to be synced with what is
|
||||||
// ! returned by Config::proxy_directory()
|
// ! returned by Config::proxy_directory()
|
||||||
let remote_proxy_path = match platform {
|
let remote_proxy_path = match platform {
|
||||||
Windows => format!("%HOMEDRIVE%%HOMEPATH%\\AppData\\Local\\lapce\\{APPLICATION_NAME}\\data\\proxy"),
|
Windows => format!(
|
||||||
Darwin => format!("~/Library/Application Support/dev.lapce.{APPLICATION_NAME}/proxy"),
|
"%HOMEDRIVE%%HOMEPATH%\\AppData\\Local\\lapce\\{}\\data\\proxy",
|
||||||
_ => format!("~/.local/share/{APPLICATION_NAME}/proxy").to_lowercase(),
|
*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 {
|
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"))?
|
.ok_or_else(|| anyhow!("can't find proxy directory"))?
|
||||||
.join(&proxy_filename);
|
.join(&proxy_filename);
|
||||||
if !local_proxy_file.exists() {
|
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");
|
let mut resp = reqwest::blocking::get(url).expect("request failed");
|
||||||
if resp.status().is_success() {
|
if resp.status().is_success() {
|
||||||
let mut out = std::fs::File::create(&local_proxy_file)
|
let mut out = std::fs::File::create(&local_proxy_file)
|
||||||
|
|
|
@ -7,12 +7,16 @@
|
||||||
pub struct Directory {}
|
pub struct Directory {}
|
||||||
|
|
||||||
impl Directory {
|
impl Directory {
|
||||||
|
fn project_dirs() -> Option<ProjectDirs> {
|
||||||
|
ProjectDirs::from("dev", "lapce", *APPLICATION_NAME)
|
||||||
|
}
|
||||||
|
|
||||||
// Get path of local data directory
|
// Get path of local data directory
|
||||||
// Local data directory differs from data directory
|
// Local data directory differs from data directory
|
||||||
// on some platforms and is not transferred across
|
// on some platforms and is not transferred across
|
||||||
// machines
|
// machines
|
||||||
pub fn data_local_directory() -> Option<PathBuf> {
|
pub fn data_local_directory() -> Option<PathBuf> {
|
||||||
match ProjectDirs::from("dev", "lapce", APPLICATION_NAME) {
|
match Self::project_dirs() {
|
||||||
Some(dir) => {
|
Some(dir) => {
|
||||||
let dir = dir.data_local_dir();
|
let dir = dir.data_local_dir();
|
||||||
if !dir.exists() {
|
if !dir.exists() {
|
||||||
|
@ -89,7 +93,7 @@ pub fn plugins_directory() -> Option<PathBuf> {
|
||||||
|
|
||||||
// Config directory contain only configuration files
|
// Config directory contain only configuration files
|
||||||
pub fn config_directory() -> Option<PathBuf> {
|
pub fn config_directory() -> Option<PathBuf> {
|
||||||
match ProjectDirs::from("dev", "lapce", APPLICATION_NAME) {
|
match Self::project_dirs() {
|
||||||
Some(dir) => {
|
Some(dir) => {
|
||||||
let dir = dir.config_dir();
|
let dir = dir.config_dir();
|
||||||
if !dir.exists() {
|
if !dir.exists() {
|
||||||
|
|
|
@ -20,21 +20,29 @@
|
||||||
};
|
};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
pub static APPLICATION_NAME: Lazy<&str> = Lazy::new(application_name);
|
||||||
pub const APPLICATION_NAME: &str = "Lapce-debug";
|
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
fn application_name() -> &'static str {
|
||||||
pub const APPLICATION_NAME: &str = "Lapce";
|
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);
|
pub static VERSION: Lazy<&str> = Lazy::new(version);
|
||||||
|
|
||||||
fn version() -> &'static str {
|
fn version() -> &'static str {
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
"debug"
|
"debug"
|
||||||
} else if option_env!("RELEASE_TAG_NAME").is_some()
|
} else if option_env!("RELEASE_TAG_NAME")
|
||||||
&& option_env!("RELEASE_TAG_NAME")
|
.unwrap_or("")
|
||||||
.unwrap()
|
.starts_with("nightly")
|
||||||
.starts_with("nightly")
|
|
||||||
{
|
{
|
||||||
option_env!("RELEASE_TAG_NAME").unwrap()
|
option_env!("RELEASE_TAG_NAME").unwrap()
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue