mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-18 23:02:31 +03:00
fix profile pictures on windows
This commit is contained in:
parent
29a9e18b66
commit
fdbf5a0184
@ -19,8 +19,6 @@ pub struct Proxy {
|
|||||||
semaphores: sync::Arc<tokio::sync::Mutex<HashMap<url::Url, Semaphore>>>,
|
semaphores: sync::Arc<tokio::sync::Mutex<HashMap<url::Url, Semaphore>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const ASSET_SCHEME: &str = "asset";
|
|
||||||
|
|
||||||
impl Proxy {
|
impl Proxy {
|
||||||
pub fn new(cache_dir: path::PathBuf) -> Self {
|
pub fn new(cache_dir: path::PathBuf) -> Self {
|
||||||
Proxy {
|
Proxy {
|
||||||
@ -139,7 +137,12 @@ impl Proxy {
|
|||||||
|
|
||||||
// takes a url of a remote assets, downloads it into cache and returns a url that points to the cached file
|
// takes a url of a remote assets, downloads it into cache and returns a url that points to the cached file
|
||||||
pub async fn proxy(&self, src: &Url) -> Result<Url> {
|
pub async fn proxy(&self, src: &Url) -> Result<Url> {
|
||||||
if src.scheme() == ASSET_SCHEME {
|
#[cfg(unix)]
|
||||||
|
if src.scheme() == "asset" {
|
||||||
|
return Ok(src.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
if src.scheme() == "https" && src.host_str() == Some("asset.localhost") {
|
||||||
return Ok(src.clone());
|
return Ok(src.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,10 +189,15 @@ impl Proxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
fn build_asset_url(path: &str) -> Url {
|
||||||
|
Url::parse(&format!("asset://localhost/{}", urlencoding::encode(path))).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
fn build_asset_url(path: &str) -> Url {
|
fn build_asset_url(path: &str) -> Url {
|
||||||
Url::parse(&format!(
|
Url::parse(&format!(
|
||||||
"{}://localhost/{}",
|
"https://asset.localhost/{}",
|
||||||
ASSET_SCHEME,
|
|
||||||
urlencoding::encode(path)
|
urlencoding::encode(path)
|
||||||
))
|
))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
Loading…
Reference in New Issue
Block a user