mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-06 00:47:09 +00:00
fix(control): add path creation before uploading
This commit is contained in:
@@ -2,6 +2,7 @@ import { db } from './database';
|
|||||||
import { get_display_by_id } from './stores/displays';
|
import { get_display_by_id } from './stores/displays';
|
||||||
import {
|
import {
|
||||||
get_current_folder_elements,
|
get_current_folder_elements,
|
||||||
|
create_path_on_all_selected_displays,
|
||||||
get_file_by_id,
|
get_file_by_id,
|
||||||
remove_all_files_without_display,
|
remove_all_files_without_display,
|
||||||
remove_file_from_display
|
remove_file_from_display
|
||||||
@@ -28,6 +29,8 @@ export async function add_upload(
|
|||||||
) {
|
) {
|
||||||
if (file_list.length === 0) return console.warn('Upload canceled: no selected files');
|
if (file_list.length === 0) return console.warn('Upload canceled: no selected files');
|
||||||
|
|
||||||
|
await create_path_on_all_selected_displays(current_file_path, selected_display_ids);
|
||||||
|
|
||||||
const used_file_names: string[] = await (
|
const used_file_names: string[] = await (
|
||||||
await get_current_folder_elements(current_file_path, selected_display_ids)
|
await get_current_folder_elements(current_file_path, selected_display_ids)
|
||||||
).map((e) => e.name);
|
).map((e) => e.name);
|
||||||
|
|||||||
@@ -377,6 +377,14 @@ export async function create_folder_on_all_selected_displays(
|
|||||||
path: string,
|
path: string,
|
||||||
selected_display_ids: string[]
|
selected_display_ids: string[]
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
const path_with_folder_name = (path += folder_name + '/');
|
||||||
|
await create_path_on_all_selected_displays(path_with_folder_name, selected_display_ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function create_path_on_all_selected_displays(
|
||||||
|
path: string,
|
||||||
|
selected_display_ids: string[]
|
||||||
|
) {
|
||||||
const path_parts = path
|
const path_parts = path
|
||||||
.slice(1, path.length - 1)
|
.slice(1, path.length - 1)
|
||||||
.split('/')
|
.split('/')
|
||||||
@@ -397,9 +405,8 @@ export async function create_folder_on_all_selected_displays(
|
|||||||
const displays = await getDisplaysForPath(currentPath);
|
const displays = await getDisplaysForPath(currentPath);
|
||||||
if (!displays.length) continue;
|
if (!displays.length) continue;
|
||||||
|
|
||||||
const folders_to_create = [...path_parts.slice(depth), folder_name];
|
|
||||||
for (const display of displays) {
|
for (const display of displays) {
|
||||||
await create_folders(display.ip, currentPath, folders_to_create);
|
await create_folders(display.ip, currentPath, path_parts.slice(depth));
|
||||||
remaining_display_ids = remaining_display_ids.filter((id) => id !== display.id);
|
remaining_display_ids = remaining_display_ids.filter((id) => id !== display.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user