sync
This commit is contained in:
@@ -287,7 +287,14 @@ export function parseIncomingFrame(view: DataView, sender: FrameSender) {
|
||||
|
||||
case FRAME.ERROR:
|
||||
const errorCode = view.getUint16(3, true);
|
||||
console.error(`Received error frame with code: 0x${errorCode.toString(16)}`);
|
||||
const errorInfo = ZEPHYR_ERRORS[errorCode];
|
||||
if (errorInfo) {
|
||||
console.error(
|
||||
`Received error frame: 0x${errorCode.toString(16).padStart(2, '0')} (${errorInfo.zephyr}) - ${errorInfo.text}`
|
||||
);
|
||||
} else {
|
||||
console.error(`Received error frame with code: 0x${errorCode.toString(16).padStart(2, '0')}`);
|
||||
}
|
||||
showErrorToast(errorCode);
|
||||
if (lsReject) {
|
||||
const currentReject = lsReject;
|
||||
@@ -361,6 +368,7 @@ export function buildFWInfoRequest(): ArrayBuffer {
|
||||
export function buildLSRequest(path: string): ArrayBuffer {
|
||||
const encoder = new TextEncoder();
|
||||
const pathBytes = encoder.encode(path);
|
||||
console.debug(`[Protocol] LS request for path: ${path}`);
|
||||
const buffer = new ArrayBuffer(4 + pathBytes.length);
|
||||
const view = new DataView(buffer);
|
||||
|
||||
@@ -442,6 +450,7 @@ export function setFileGetResolver(
|
||||
export function buildFileGetRequest(path: string): ArrayBuffer {
|
||||
const encoder = new TextEncoder();
|
||||
const pathBytes = encoder.encode(path);
|
||||
console.debug(`[Protocol] FILE_GET request for path: ${path}`);
|
||||
const buffer = new ArrayBuffer(4 + pathBytes.length);
|
||||
const view = new DataView(buffer);
|
||||
|
||||
@@ -458,6 +467,7 @@ export function buildFileGetRequest(path: string): ArrayBuffer {
|
||||
export function buildTagsGetRequest(path: string): ArrayBuffer {
|
||||
const encoder = new TextEncoder();
|
||||
const pathBytes = encoder.encode(path);
|
||||
console.debug(`[Protocol] TAGS_GET request for path: ${path}`);
|
||||
const buffer = new ArrayBuffer(4 + pathBytes.length);
|
||||
const view = new DataView(buffer);
|
||||
|
||||
|
||||
@@ -34,12 +34,18 @@ export async function refreshRemote() {
|
||||
await new Promise(r => setTimeout(r, 100));
|
||||
|
||||
const currentFsInfo = get(fsInfo);
|
||||
console.debug("[Sync] Remote FS info:", currentFsInfo);
|
||||
|
||||
// Sequenzielle Abfrage via Transport-Layer
|
||||
const sysFiles = await fetchDirectory(currentFsInfo?.sysPath || "/lfs/sys");
|
||||
const sysPath = currentFsInfo?.sysPath || "/lfs/sys";
|
||||
const audioPath = currentFsInfo?.audioPath || "/lfs/a";
|
||||
|
||||
console.debug(`[Sync] Listing system directory: ${sysPath}`);
|
||||
const sysFiles = await fetchDirectory(sysPath);
|
||||
buzzerSysFiles.set(sysFiles.map(mapToBuzzerFile));
|
||||
|
||||
const audioFiles = await fetchDirectory(currentFsInfo?.audioPath || "/lfs/a");
|
||||
console.debug(`[Sync] Listing audio directory: ${audioPath}`);
|
||||
const audioFiles = await fetchDirectory(audioPath);
|
||||
let mappedAudio = audioFiles.map(mapToBuzzerFile);
|
||||
|
||||
// Dateien sofort im UI anzeigen, bevor die Tags geladen sind
|
||||
@@ -101,6 +107,7 @@ export async function refreshLocal() {
|
||||
export async function downloadSelectedFiles() {
|
||||
const files = get(buzzerAudioFiles).filter(f => f.selected);
|
||||
const pathPrefix = get(fsInfo)?.audioPath || "/lfs/a";
|
||||
console.debug(`[Sync] Download prefix: ${pathPrefix}`);
|
||||
|
||||
if (files.length === 0) {
|
||||
addToast("Keine Dateien zum Herunterladen ausgewählt.", "warning");
|
||||
@@ -181,6 +188,7 @@ export async function deleteSelectedLocalFiles() {
|
||||
export async function deleteSelectedRemoteFiles() {
|
||||
const files = get(buzzerAudioFiles).filter(f => f.selected);
|
||||
const pathPrefix = get(fsInfo)?.audioPath || "/lfs/a";
|
||||
console.debug(`[Sync] Delete prefix: ${pathPrefix}`);
|
||||
|
||||
if (files.length === 0) return;
|
||||
|
||||
@@ -208,6 +216,7 @@ export async function deleteSelectedRemoteFiles() {
|
||||
export async function uploadSelectedFiles() {
|
||||
const files = get(localAudioFiles).filter(f => f.selected);
|
||||
const pathPrefix = get(fsInfo)?.audioPath || "/lfs/a";
|
||||
console.debug(`[Sync] Upload prefix: ${pathPrefix}`);
|
||||
|
||||
if (files.length === 0) {
|
||||
addToast("Keine Dateien zum Hochladen ausgewählt.", "warning");
|
||||
|
||||
@@ -66,6 +66,8 @@ export async function fetchDirectory(path: string): Promise<any[]> {
|
||||
}
|
||||
isListing = true;
|
||||
|
||||
console.debug(`[Transport] fetchDirectory(${path})`);
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
// Dem Parser sagen, wen er bei Erfolg/Fehler anrufen soll
|
||||
setLsResolver(
|
||||
@@ -95,6 +97,8 @@ export async function getFile(path: string): Promise<boolean> {
|
||||
}
|
||||
isFileTransferring = true;
|
||||
|
||||
console.debug(`[Transport] getFile(${path})`);
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
setFileGetResolver(
|
||||
(result: any) => { isFileTransferring = false; resolve(result.success); },
|
||||
@@ -116,6 +120,8 @@ export async function getTags(path: string): Promise<Blob> {
|
||||
}
|
||||
isFileTransferring = true;
|
||||
|
||||
console.debug(`[Transport] getTags(${path})`);
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
setFileGetResolver(
|
||||
(result: any) => {
|
||||
|
||||
Reference in New Issue
Block a user