From 5994e6e1172023f56b8eb335df637440f71041d0 Mon Sep 17 00:00:00 2001 From: Ossama Jouini Date: Sun, 25 Jan 2026 12:55:17 +0100 Subject: [PATCH 1/2] Added write base64 file and trying to fix Poki upload --- .../app/src/handlers/fs/write-base64.js | 32 +++++++++++++++++++ assets/electron/template/app/src/index.js | 7 ++++ src/shared/libs/plugin-poki/export.ts | 9 ++++-- 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 assets/electron/template/app/src/handlers/fs/write-base64.js diff --git a/assets/electron/template/app/src/handlers/fs/write-base64.js b/assets/electron/template/app/src/handlers/fs/write-base64.js new file mode 100644 index 00000000..25b0dc34 --- /dev/null +++ b/assets/electron/template/app/src/handlers/fs/write-base64.js @@ -0,0 +1,32 @@ +// @ts-check + +import { mkdir, writeFile } from 'node:fs/promises' +import { dirname } from 'node:path' + +/** + * @param {{url: string, correlationId?: string, body: {path: string, base64Data: string, flag?: string}}} json + * @param {import('ws').WebSocket} ws + */ +export default async (json, ws) => { + const destDirName = dirname(json.body.path) + await mkdir(destDirName, { recursive: true }) + + // Decode base64 string to buffer + const buffer = Buffer.from(json.body.base64Data, 'base64') + + await writeFile(json.body.path, buffer, { + flag: json.body.flag + }) + + /** + * @type {{url: string, correlationId?: string, body: {success: boolean}}} + */ + const writeFileResult = { + correlationId: json.correlationId, + url: json.url, + body: { + success: true + } + } + ws.send(JSON.stringify(writeFileResult)) +} diff --git a/assets/electron/template/app/src/index.js b/assets/electron/template/app/src/index.js index 355906c4..55ec7d4e 100644 --- a/assets/electron/template/app/src/index.js +++ b/assets/electron/template/app/src/index.js @@ -17,6 +17,7 @@ import userFolder from './handlers/user/folder.js' // fs import fsWrite from './handlers/fs/write.js' +import fsWriteBase64 from './handlers/fs/write-base64.js' import fsRead from './handlers/fs/read.js' import fsReadBinary from './handlers/fs/read-binary.js' import fsFolderCreate from './handlers/fs/folder-create.js' @@ -228,6 +229,8 @@ if (config.enableDiscordSupport) { console.log('rpc', rpc) } +// Fix for ICU data loading issues +app.commandLine.appendSwitch('no-sandbox') //region commandLine Flags if (config.enableInProcessGPU) { app.commandLine.appendSwitch('in-process-gpu') @@ -353,6 +356,10 @@ const createAppServer = (mainWindow, serveStatic = true) => { await fsWrite(json, ws) break + case '/fs/file/write-base64': + await fsWriteBase64(json, ws) + break + case '/fs/file/read': await fsRead(json, ws) break diff --git a/src/shared/libs/plugin-poki/export.ts b/src/shared/libs/plugin-poki/export.ts index b4313a81..646cc213 100644 --- a/src/shared/libs/plugin-poki/export.ts +++ b/src/shared/libs/plugin-poki/export.ts @@ -1,4 +1,5 @@ import { createAction, createActionRunner, createPathParam, createStringParam, runWithLiveLogs } from '@pipelab/plugin-core' +import { dirname } from 'node:path' export const ID = 'poki-upload' @@ -42,8 +43,8 @@ export const uploadToPoki = createAction({ export const uploadToPokiRunner = createActionRunner( async ({ log, inputs, paths, abortSignal, cwd }) => { - const { join } = await import('node:path') - const { writeFile , cp, mkdir } = await import('node:fs/promises') + const { join, basename, delimiter } = await import('node:path') + const { writeFile, cp, mkdir } = await import('node:fs/promises') const { shell } = await import('electron') const { unpack } = paths @@ -82,6 +83,10 @@ export const uploadToPokiRunner = createActionRunner( ['upload', '--name', inputs.name, '--notes', inputs.notes], { cwd, + env: { + // DEBUG: '*', + PATH: `${dirname(poki)}${delimiter}${process.env.PATH}`, + }, cancelSignal: abortSignal, }, log, From 3e219f6c9f0e73ad45ab42929ef9495e07fae161 Mon Sep 17 00:00:00 2001 From: Ossama Jouini Date: Mon, 26 Jan 2026 00:10:15 +0100 Subject: [PATCH 2/2] removed unnecessary no sandbox --- assets/electron/template/app/src/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/assets/electron/template/app/src/index.js b/assets/electron/template/app/src/index.js index 9d3cd71d..fa164aec 100644 --- a/assets/electron/template/app/src/index.js +++ b/assets/electron/template/app/src/index.js @@ -229,8 +229,6 @@ if (config.enableDiscordSupport) { console.log('rpc', rpc) } -// Fix for ICU data loading issues -app.commandLine.appendSwitch('no-sandbox') //region commandLine Flags if (config.enableInProcessGPU) { app.commandLine.appendSwitch('in-process-gpu')