From b3d99f33342d745bfad933b430f304c4801bf030 Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Thu, 26 Feb 2026 13:24:58 +0530 Subject: [PATCH] refactor: use echo to write manifest on flatpak --- src-tauri/capabilities/default.json | 1 - src-tauri/capabilities/shell.json | 5 +++++ src/helpers/use-linux-registerer.ts | 22 ++++++++++++++-------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 8db51bb..8de15af 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -24,7 +24,6 @@ "sql:allow-execute", "fs:allow-app-write", "fs:allow-app-write-recursive", - "fs:allow-write-text-file", "updater:default", "process:default", "clipboard-manager:allow-read-text", diff --git a/src-tauri/capabilities/shell.json b/src-tauri/capabilities/shell.json index 8f310b9..43ea75f 100644 --- a/src-tauri/capabilities/shell.json +++ b/src-tauri/capabilities/shell.json @@ -69,6 +69,11 @@ "name": "cp", "cmd": "cp", "args": true + }, + { + "name": "echo", + "cmd": "echo", + "args": true } ] }, diff --git a/src/helpers/use-linux-registerer.ts b/src/helpers/use-linux-registerer.ts index e07e8a3..edc69b9 100644 --- a/src/helpers/use-linux-registerer.ts +++ b/src/helpers/use-linux-registerer.ts @@ -56,20 +56,26 @@ export function useLinuxRegisterer() { for (const file of filesToCopyFlatpak) { const sourcePath = await join(resourceDirPath, file.source); const destinationPath = await join(homeDirPath, file.destination); - const command = Command.create('cp', [sourcePath, destinationPath]); + const copyCommand = Command.create('cp', [sourcePath, destinationPath]); - const output = await command.execute(); - if (output.code === 0) { + const copyOutput = await copyCommand.execute(); + if (copyOutput.code === 0) { console.log(`File ${file.source} copied successfully to ${destinationPath}`); LOG.info("LINUX REGISTERER", `File ${file.source} copied successfully to ${destinationPath}`); if (file.content) { - await fs.writeTextFile(destinationPath, file.content); - console.log(`Content for ${file.source} written successfully to ${destinationPath}`); - LOG.info("LINUX REGISTERER", `Content for ${file.source} written successfully to ${destinationPath}`); + const writeCommand = Command.create('echo', [file.content, '>', destinationPath]); + const writeOutput = await writeCommand.execute(); + if (writeOutput.code === 0) { + console.log(`Content written successfully to ${destinationPath}`); + LOG.info("LINUX REGISTERER", `Content written successfully to ${destinationPath}`); + } else { + console.error(`Failed to write content to ${destinationPath}:`, writeOutput.stderr); + LOG.error("LINUX REGISTERER", `Failed to write content to ${destinationPath}: ${writeOutput.stderr}`); + } } } else { - console.error(`Failed to copy file ${file.source} to ${destinationPath}:`, output.stderr); - LOG.error("LINUX REGISTERER", `Failed to copy file ${file.source} to ${destinationPath}: ${output.stderr}`); + console.error(`Failed to copy file ${file.source} to ${destinationPath}:`, copyOutput.stderr); + LOG.error("LINUX REGISTERER", `Failed to copy file ${file.source} to ${destinationPath}: ${copyOutput.stderr}`); } } } else {