Revert "Merge branch 'master' into ian/gb-187-cmdpal-icons-for-repository-and-files"

This reverts commit 6b74d3f0f9, reversing
changes made to 57e6db78ad.
This commit is contained in:
Ian Donahue 2023-04-06 19:51:29 +02:00
parent ee184ebe8e
commit bc636c3786
3 changed files with 10 additions and 30 deletions

1
src-tauri/Cargo.lock generated
View File

@ -1296,7 +1296,6 @@ dependencies = [
"futures",
"futures-util",
"git2",
"http",
"log",
"md5",
"notify",

View File

@ -45,7 +45,6 @@ bytes = "1.1.0"
futures = "0.3"
futures-util = "0.3.8"
timed = "0.2.1"
http = "0.2.9"
[features]
# by default Tauri runs in production mode

View File

@ -6,7 +6,8 @@ use portable_pty::{native_pty_system, CommandBuilder, PtySize};
use std::env;
use std::io::{Read, Write};
use tokio::net;
use tokio_tungstenite::tungstenite::handshake::server::{ErrorResponse, Request, Response};
use tokio_tungstenite;
use tokio_tungstenite::tungstenite::handshake::server::{Request, Response};
const TERM: &str = "xterm-256color";
@ -15,38 +16,19 @@ pub async fn accept_connection(
stream: net::TcpStream,
) -> Result<()> {
let mut project = None;
let copy_uri_callback =
|req: &Request, response: Response| -> Result<Response, ErrorResponse> {
let path = req.uri().path().to_string();
let project_id = match path.split("/").last() {
Some(project_id) => project_id,
None => {
return Err(http::response::Response::builder()
.status(http::StatusCode::NOT_FOUND)
.body(None)
.unwrap());
}
};
let copy_uri_callback = |req: &Request, response: Response| {
let path = req.uri().path().to_string();
if let Some(project_id) = path.split("/").last() {
project = match projects_store.get_project(project_id) {
Ok(Some(p)) => Some(p),
Ok(None) => {
return Err(http::response::Response::builder()
.status(http::StatusCode::NOT_FOUND)
.body(None)
.unwrap());
}
Ok(p) => p,
Err(e) => {
log::error!("failed to get project: {}", e);
return Err(http::response::Response::builder()
.status(http::StatusCode::INTERNAL_SERVER_ERROR)
.body(None)
.unwrap());
None
}
};
Ok(response)
};
}
Ok(response)
};
let mut ws_stream = tokio_tungstenite::accept_hdr_async(stream, copy_uri_callback)
.await