add more efficient file update structure (tree command)

This commit is contained in:
E44
2025-11-08 20:07:35 +01:00
parent c117cb2199
commit c579c9ae2c
2 changed files with 67 additions and 9 deletions
+15 -1
View File
@@ -1,5 +1,5 @@
import { notifications } from "./stores/notification";
import { to_display_status, type DisplayStatus, type FolderElement } from "./types";
import { to_display_status, type DisplayStatus, type FolderElement, type TreeElement } from "./types";
import { get_uuid } from "./utils";
export async function get_screenshot(ip: string) {
@@ -74,6 +74,20 @@ done
return folder_element_list;
}
export async function get_file_tree_data(ip: string, path: string): Promise<TreeElement[]|null> {
const options = {
method: 'PATCH',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
command: `cd ".${path}" && tree -Js`
})
};
const raw_response = await request_display(ip, '/shellCommand', options);
if (!raw_response) return null;
const tree_structure: TreeElement[]|null = (JSON.parse(raw_response.stdout.trim()) as [TreeElement, any])[0].contents || null;
return tree_structure;
}
export async function ping_ip(ip: string): Promise<DisplayStatus> {