Skip to content

Commit

Permalink
Try to fix windows shell open calls
Browse files Browse the repository at this point in the history
Issue #80
  • Loading branch information
qu1ck committed Sep 17, 2023
1 parent 5d2e9fd commit 44e964b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ pub async fn remove_file(path: String) {

#[tauri::command]
pub async fn shell_open(path: String) -> Result<(), String> {
#[cfg(target_os = "windows")]
let path = path.replace('/', "\\");

if let Err(e) = opener::open(path) {
return Err(e.to_string());
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/tables/filetreetable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,11 @@ export function FileTreeTable(props: FileTreeTableProps) {
const onRowDoubleClick = useCallback((row: FileDirEntry) => {
if (TAURI) {
if (props.downloadDir === undefined || props.downloadDir === "") return;
let path = `${props.downloadDir}/${row.fullpath}`;
let path = props.downloadDir;
if (!path.endsWith("/") && !path.endsWith("\\")) {
path = path + "/";
}
path = path + row.fullpath + (isDirEntry(row) ? "/" : "");
path = pathMapFromServer(path, serverConfig);
invoke("shell_open", { path }).catch((e) => {
notifications.show({
Expand Down
4 changes: 1 addition & 3 deletions src/trutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ export function reorderElements<T>(list: T[], startIndex: number, endIndex: numb
}

function normalizePath(path: string) {
let p = path.replace(/\\/g, "/");
if (p.match(/^[a-zA-Z]:\//) != null) p = p.toLowerCase();
return p;
return path.replace(/\\/g, "/");
}

export function pathMapFromServer(path: string, config: ServerConfig) {
Expand Down

0 comments on commit 44e964b

Please sign in to comment.