mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-06 00:47:09 +00:00
chore(control): add backend of sync, visuals still buggy
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
import RefreshPlay from '../svgs/RefreshPlay.svelte';
|
||||
import { get_file_size_display_string, get_file_type } from '$lib/ts/utils';
|
||||
import { open_file } from '$lib/ts/api_handler';
|
||||
import { run_on_all_selected_displays } from '$lib/ts/stores/displays';
|
||||
import { get_display_by_id, run_on_all_selected_displays } from '$lib/ts/stores/displays';
|
||||
import { get_thumbnail_url } from '$lib/ts/stores/thumbnails';
|
||||
import { liveQuery, type Observable } from 'dexie';
|
||||
import { db } from '$lib/ts/database';
|
||||
@@ -215,7 +215,17 @@
|
||||
if (!is_loading) is_loading = true;
|
||||
percentage_sum += fod.loading_data.percentage;
|
||||
total_seconds_until_finish += fod.loading_data.seconds_until_finish;
|
||||
display_data.push(fod.loading_data);
|
||||
const display = await get_display_by_id(fod.display_id);
|
||||
if (!display) continue;
|
||||
const display_data_element = {
|
||||
loading_data: fod.loading_data,
|
||||
display_name: display.name
|
||||
};
|
||||
if (fod.loading_data.type === 'sync_download') {
|
||||
display_data.unshift(display_data_element); // insert sync_download element at beginning
|
||||
} else {
|
||||
display_data.push(display_data_element);
|
||||
}
|
||||
} else {
|
||||
percentage_sum += 100;
|
||||
}
|
||||
|
||||
@@ -89,13 +89,32 @@ export async function add_upload(
|
||||
await start_task_processing();
|
||||
}
|
||||
|
||||
export async function add_sync(selected_file_id: string, selected_display_ids: string[]) {
|
||||
export async function add_sync_recursively(
|
||||
selected_file_id: string,
|
||||
selected_display_ids: string[]
|
||||
) {
|
||||
const file_data = await find_file_data_on_active_selected_display(
|
||||
selected_file_id,
|
||||
selected_display_ids
|
||||
);
|
||||
if (!file_data) return console.warn('Sync canceled: no file_data');
|
||||
|
||||
if (file_data.file.type === 'inode/directory') {
|
||||
const new_path = file_data.file.path + file_data.file.name + '/';
|
||||
const elements_in_folder = await get_folder_elements(new_path, selected_display_ids);
|
||||
if (elements_in_folder.length === 0) {
|
||||
await create_path_on_all_selected_displays(new_path, selected_display_ids);
|
||||
} else {
|
||||
for (const el of elements_in_folder) {
|
||||
await add_sync_recursively(get_file_primary_key(el), selected_display_ids);
|
||||
}
|
||||
}
|
||||
return; // cannot sync folder
|
||||
}
|
||||
|
||||
if (file_data.short_displays_without_file.length === 0) return; // file is present on all selected displays
|
||||
await create_path_on_all_selected_displays(file_data.file.path, selected_display_ids);
|
||||
|
||||
tasks.push({
|
||||
data: {
|
||||
type: 'sync',
|
||||
|
||||
Reference in New Issue
Block a user