From 70b381d1f924a2b8f5d3f6d960df33213f9b077b Mon Sep 17 00:00:00 2001 From: E44 <129310925+programmer-44@users.noreply.github.com> Date: Sun, 23 Nov 2025 00:58:59 +0100 Subject: [PATCH] fix(control): fix create folder on main level path --- control/frontend/src/ts/api_handler.ts | 2 +- control/frontend/src/ts/stores/files.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/control/frontend/src/ts/api_handler.ts b/control/frontend/src/ts/api_handler.ts index 03c6949..f2a74ce 100644 --- a/control/frontend/src/ts/api_handler.ts +++ b/control/frontend/src/ts/api_handler.ts @@ -103,7 +103,7 @@ export async function create_folders(ip: string, path: string, folder_names: str let command = `cd ".${path}"`; for (const part of folder_names) { - command += `&& mkdir "${part}" && cd "${part}/"`; + command += ` && mkdir "${part}" && cd "${part}/"`; } const raw_response = await run_shell_command(ip, command); diff --git a/control/frontend/src/ts/stores/files.ts b/control/frontend/src/ts/stores/files.ts index b4eea8f..a65e5db 100644 --- a/control/frontend/src/ts/stores/files.ts +++ b/control/frontend/src/ts/stores/files.ts @@ -298,9 +298,9 @@ export async function run_for_selected_files_on_selected_displays(action: (ip: s } export function get_longest_existing_path_and_needed_parts(path: string, display_id: string, all_files: Record>): { existing: string; needed: string[] } { - const path_parts = path.slice(0, path.length - 1).split('/'); - for (let i = path_parts.length; i > 1; i--) { - const current_path = [...path_parts].splice(0, i).join('/') + '/';; + const path_parts = path.slice(1, path.length - 1).split('/').filter(e => e.length !== 0); // remove front and back / and split after that, then remove empty strings + for (let i = path_parts.length; i > 0; i--) { + const current_path = '/' + [...path_parts].splice(0, i).join('/') + '/';; if (all_files.hasOwnProperty(current_path)) { if (all_files[current_path].hasOwnProperty(display_id)) { return { existing: current_path, needed: [...path_parts].splice(i) };