Convert UNC paths in more places

This commit is contained in:
Gregory Schier
2024-07-25 07:47:00 -07:00
parent 6ffb0015c6
commit 80777f712c
6 changed files with 37 additions and 25 deletions

View File

@@ -382,17 +382,17 @@ export const PluginRuntimeDefinition = {
responseStream: false,
options: {},
},
hookResponseFilter: {
name: "hookResponseFilter",
requestType: HookResponseFilterRequest,
hookExport: {
name: "hookExport",
requestType: HookExportRequest,
requestStream: false,
responseType: HookResponse,
responseStream: false,
options: {},
},
hookExport: {
name: "hookExport",
requestType: HookExportRequest,
hookResponseFilter: {
name: "hookResponseFilter",
requestType: HookResponseFilterRequest,
requestStream: false,
responseType: HookResponse,
responseStream: false,
@@ -403,20 +403,20 @@ export const PluginRuntimeDefinition = {
export interface PluginRuntimeServiceImplementation<CallContextExt = {}> {
hookImport(request: HookImportRequest, context: CallContext & CallContextExt): Promise<DeepPartial<HookResponse>>;
hookExport(request: HookExportRequest, context: CallContext & CallContextExt): Promise<DeepPartial<HookResponse>>;
hookResponseFilter(
request: HookResponseFilterRequest,
context: CallContext & CallContextExt,
): Promise<DeepPartial<HookResponse>>;
hookExport(request: HookExportRequest, context: CallContext & CallContextExt): Promise<DeepPartial<HookResponse>>;
}
export interface PluginRuntimeClient<CallOptionsExt = {}> {
hookImport(request: DeepPartial<HookImportRequest>, options?: CallOptions & CallOptionsExt): Promise<HookResponse>;
hookExport(request: DeepPartial<HookExportRequest>, options?: CallOptions & CallOptionsExt): Promise<HookResponse>;
hookResponseFilter(
request: DeepPartial<HookResponseFilterRequest>,
options?: CallOptions & CallOptionsExt,
): Promise<HookResponse>;
hookExport(request: DeepPartial<HookExportRequest>, options?: CallOptions & CallOptionsExt): Promise<HookResponse>;
}
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

2
src-tauri/Cargo.lock generated
View File

@@ -2033,6 +2033,7 @@ name = "grpc"
version = "0.1.0"
dependencies = [
"anyhow",
"dunce",
"hyper 0.14.29",
"hyper-rustls 0.24.2",
"log",
@@ -3874,6 +3875,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"command-group",
"dunce",
"log",
"prost 0.13.1",
"rand 0.8.5",

View File

@@ -21,3 +21,4 @@ uuid = { version = "1.7.0", features = ["v4"] }
tauri = { version = "2.0.0-beta" }
tauri-plugin-shell = "2.0.0-beta"
md5 = "0.7.0"
dunce = "1.0.4"

View File

@@ -1,6 +1,6 @@
use std::env::temp_dir;
use std::ops::Deref;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use anyhow::anyhow;
@@ -35,12 +35,15 @@ pub async fn fill_pool_from_files(
let global_import_dir = app_handle
.path()
.resolve("protoc-include", BaseDirectory::Resource)
.expect("failed to resolve protoc include directory")
.to_string_lossy()
.to_string();
.expect("failed to resolve protoc include directory");
// HACK: Remove UNC prefix for Windows paths
let global_import_dir = global_import_dir.replace("\\\\?\\", "");
let global_import_dir = dunce::simplified(&Path::from(global_import_dir))
.to_string_lossy()
.to_string();
let desc_path = dunce::simplified(&Path::from(desc_path))
.to_string_lossy()
.to_string();
let mut args = vec![
"--include_imports".to_string(),
@@ -48,7 +51,7 @@ pub async fn fill_pool_from_files(
"-I".to_string(),
global_import_dir,
"-o".to_string(),
desc_path.to_string_lossy().to_string(),
desc_path,
];
for p in paths {

View File

@@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
anyhow = "1.0.86"
command-group = "5.0.1"
dunce = "1.0.4"
log = "0.4.21"
prost = "0.13.1"
rand = "0.8.5"

View File

@@ -1,4 +1,4 @@
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::time::Duration;
@@ -7,8 +7,8 @@ use log::{debug, info};
use rand::distributions::{Alphanumeric, DistString};
use serde;
use serde::Deserialize;
use tauri::{AppHandle, Manager, Runtime};
use tauri::path::BaseDirectory;
use tauri::{AppHandle, Manager, Runtime};
use tauri_plugin_shell::ShellExt;
use tokio::fs;
@@ -29,23 +29,28 @@ pub async fn node_start<R: Runtime>(app: &AppHandle<R>, temp_dir: &PathBuf) -> S
let plugins_dir = app
.path()
.resolve("plugins", BaseDirectory::Resource)
.expect("failed to resolve plugin directory resource")
.to_string_lossy()
.to_string();
.expect("failed to resolve plugin directory resource");
let plugin_runtime_dir = app
let plugin_runtime_main = app
.path()
.resolve("plugin-runtime", BaseDirectory::Resource)
.expect("failed to resolve plugin runtime resource");
.expect("failed to resolve plugin runtime resource")
.join("index.cjs");
// HACK: Remove UNC prefix for Windows paths
let plugins_dir = plugins_dir.replace("\\\\?\\", "");
// HACK: Remove UNC prefix for Windows paths to pass to sidecar
let plugins_dir = dunce::simplified(&Path::from(plugins_dir))
.to_string_lossy()
.to_string();
let plugin_runtime_main = dunce::simplified(&Path::from(plugin_runtime_main))
.to_string_lossy()
.to_string();
info!(
"Starting plugin runtime\n port_file={}\n plugins_dir={}\n runtime_dir={}",
port_file_path.to_string_lossy(),
plugins_dir,
plugin_runtime_dir.to_string_lossy(),
plugin_runtime_main,
);
let cmd = app
@@ -54,7 +59,7 @@ pub async fn node_start<R: Runtime>(app: &AppHandle<R>, temp_dir: &PathBuf) -> S
.expect("yaaknode not found")
.env("YAAK_GRPC_PORT_FILE_PATH", port_file_path.clone())
.env("YAAK_PLUGINS_DIR", plugins_dir)
.args(&[plugin_runtime_dir.join("index.cjs")]);
.args(&[plugin_runtime_main]);
let child = Command::from(cmd)
.group_spawn()