Skip to content

Commit 8ff94a5

Browse files
committed
Merge branch 'master' of https://github.com/cleboost/rustmius
2 parents 40ab5c5 + 45ea5cf commit 8ff94a5

File tree

4 files changed

+758
-60
lines changed

4 files changed

+758
-60
lines changed

src-tauri/capabilities/default.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"fs:allow-read-dir",
1515
"fs:allow-exists",
1616
"fs:allow-write-text-file",
17+
"fs:allow-remove",
1718
"fs:scope-home-recursive",
1819
{
1920
"identifier": "fs:scope",
@@ -32,6 +33,7 @@
3233
{ "name": "ssh", "cmd": "ssh", "args": true },
3334
{ "name": "sshpass", "cmd": "sshpass", "args": true },
3435
{ "name": "ssh-copy-id", "cmd": "ssh-copy-id", "args": true },
36+
{ "name": "ssh-keygen", "cmd": "ssh-keygen", "args": true },
3537
{ "name": "foot", "cmd": "foot", "args": true },
3638
{ "name": "footclient", "cmd": "footclient", "args": true },
3739
{ "name": "alacritty", "cmd": "alacritty", "args": true },
@@ -49,6 +51,7 @@
4951
"identifier": "shell:allow-spawn",
5052
"allow": [
5153
{ "name": "ssh", "cmd": "ssh", "args": true },
54+
{ "name": "ssh-keygen", "cmd": "ssh-keygen", "args": true },
5255
{ "name": "foot", "cmd": "foot", "args": true },
5356
{ "name": "footclient", "cmd": "footclient", "args": true },
5457
{ "name": "alacritty", "cmd": "alacritty", "args": true },

src/main.ts

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { createPinia } from "pinia";
66
import { useSettingsStore } from "@/stores/settings";
77
import { useKeysStore } from "./stores/keys";
88
import { useServerConfigStore } from "./stores/servers";
9-
import { readDir, exists } from "@tauri-apps/plugin-fs";
10-
import { homeDir, join, BaseDirectory } from "@tauri-apps/api/path";
119

1210
import "@/index.css";
1311

@@ -34,61 +32,6 @@ async function initAppSetttings() {
3432
mode.value = theme;
3533
}
3634

37-
await ensureSshKeysSynced();
35+
await useKeysStore().syncWithFs();
3836
await useServerConfigStore().load();
3937
}
40-
41-
async function ensureSshKeysSynced() {
42-
const keysStore = useKeysStore();
43-
await keysStore.load();
44-
45-
const home = await homeDir();
46-
const sshRel = ".ssh";
47-
const sshAbs = await join(home, ".ssh");
48-
const entries = await readDir(sshRel, { baseDir: BaseDirectory.Home });
49-
const scanned: Array<{ name: string; private: string; public?: string }> = [];
50-
for (const e of entries) {
51-
if (e.isDirectory) continue;
52-
const name = e.name ?? "";
53-
if (!name.endsWith(".pub")) {
54-
continue;
55-
}
56-
const stem = name.slice(0, -4);
57-
if (!stem || stem === "config" || stem.startsWith("known_hosts")) {
58-
continue;
59-
}
60-
const privateRel = `${sshRel}/${stem}`;
61-
const hasPrivate = await exists(privateRel, {
62-
baseDir: BaseDirectory.Home,
63-
});
64-
if (!hasPrivate) {
65-
continue; // require private key pair
66-
}
67-
const publicPath = await join(sshAbs, name);
68-
const privatePath = await join(sshAbs, stem);
69-
scanned.push({ name: stem, private: privatePath, public: publicPath });
70-
}
71-
72-
const existing = await keysStore.getKeys();
73-
const byPrivate = new Map(existing.map((k) => [k.private, k]));
74-
75-
for (const s of scanned) {
76-
const found = byPrivate.get(s.private);
77-
if (found) {
78-
if (found.name !== s.name || found.public !== s.public) {
79-
await keysStore.addOrUpdateKey({
80-
id: found.id,
81-
name: s.name,
82-
private: s.private,
83-
public: s.public,
84-
});
85-
}
86-
} else {
87-
await keysStore.addOrUpdateKey({
88-
name: s.name,
89-
private: s.private,
90-
public: s.public,
91-
});
92-
}
93-
}
94-
}

0 commit comments

Comments
 (0)