mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-06 00:47:09 +00:00
fix(control): folders could only be created in path '/'
This commit is contained in:
@@ -125,19 +125,23 @@ export async function get_displays_where_path_exists(
|
|||||||
const path_without_last_part = path.slice(0, path.length - (last_path_part.length + 1));
|
const path_without_last_part = path.slice(0, path.length - (last_path_part.length + 1));
|
||||||
|
|
||||||
const folders_of_current_path = await db.files
|
const folders_of_current_path = await db.files
|
||||||
.where('[path+name+type]')
|
.where('name')
|
||||||
.equals([path_without_last_part, last_path_part, 'inode/directory'])
|
.equals(last_path_part)
|
||||||
|
.filter((inode) => inode.path === path_without_last_part && inode.type === 'inode/directory')
|
||||||
.first();
|
.first();
|
||||||
if (!folders_of_current_path)
|
if (!folders_of_current_path)
|
||||||
return await db.displays.where('id').anyOf(selected_display_ids).toArray();
|
return await db.displays.where('id').anyOf(selected_display_ids).toArray();
|
||||||
const folder_primary_key = get_file_primary_key(folders_of_current_path);
|
const folder_primary_key = get_file_primary_key(folders_of_current_path);
|
||||||
|
|
||||||
const display_ids = selected_display_ids.filter(async (display_id) => {
|
const display_ids_with_folder = (
|
||||||
const folder_exists = await db.files_on_display.get([display_id, folder_primary_key]);
|
await db.files_on_display.where('file_primary_key').equals(folder_primary_key).toArray()
|
||||||
|
).map((fod) => fod.display_id);
|
||||||
|
|
||||||
|
const display_ids = selected_display_ids.filter((display_id) => {
|
||||||
if (invert) {
|
if (invert) {
|
||||||
return !folder_exists;
|
return !display_ids_with_folder.includes(display_id);
|
||||||
} else {
|
} else {
|
||||||
return folder_exists;
|
return display_ids_with_folder.includes(display_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user