From 953bd2049997d05c642f6bc0b3eab86eafeaa1b1 Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Thu, 26 Feb 2026 11:59:06 +0530 Subject: [PATCH] refactor: revert back to cp again --- src-tauri/capabilities/default.json | 4 ---- src-tauri/capabilities/shell.json | 5 +++++ src/helpers/use-linux-registerer.ts | 21 ++++++--------------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 3af426d..8db51bb 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -24,10 +24,6 @@ "sql:allow-execute", "fs:allow-app-write", "fs:allow-app-write-recursive", - "fs:allow-config-read", - "fs:allow-config-read-recursive", - "fs:allow-config-write", - "fs:allow-config-write-recursive", "fs:allow-write-text-file", "updater:default", "process:default", diff --git a/src-tauri/capabilities/shell.json b/src-tauri/capabilities/shell.json index 700908f..8f310b9 100644 --- a/src-tauri/capabilities/shell.json +++ b/src-tauri/capabilities/shell.json @@ -64,6 +64,11 @@ "name": "powershell", "cmd": "powershell", "args": true + }, + { + "name": "cp", + "cmd": "cp", + "args": true } ] }, diff --git a/src/helpers/use-linux-registerer.ts b/src/helpers/use-linux-registerer.ts index 2fb926b..e07e8a3 100644 --- a/src/helpers/use-linux-registerer.ts +++ b/src/helpers/use-linux-registerer.ts @@ -4,6 +4,7 @@ import { useKvPairs } from "@/helpers/use-kvpairs"; import { useSettingsPageStatesStore } from "@/services/store"; import { invoke } from "@tauri-apps/api/core"; import { useLogger } from "@/helpers/use-logger"; +import { Command } from "@tauri-apps/plugin-shell"; interface FileMap { source: string; @@ -54,12 +55,11 @@ export function useLinuxRegisterer() { if (isFlatpak) { for (const file of filesToCopyFlatpak) { const sourcePath = await join(resourceDirPath, file.source); - const destinationDir = await join(homeDirPath, file.dir); const destinationPath = await join(homeDirPath, file.destination); + const command = Command.create('cp', [sourcePath, destinationPath]); - const dirExists = await fs.exists(destinationDir); - if (dirExists) { - await fs.copyFile(sourcePath, destinationPath); + const output = await command.execute(); + if (output.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) { @@ -68,17 +68,8 @@ export function useLinuxRegisterer() { LOG.info("LINUX REGISTERER", `Content for ${file.source} written successfully to ${destinationPath}`); } } else { - await fs.mkdir(destinationDir, { recursive: true }) - console.log(`Created dir ${destinationDir}`); - LOG.info("LINUX REGISTERER", `Created dir ${destinationDir}`); - await fs.copyFile(sourcePath, destinationPath); - 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}`); - } + 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}`); } } } else {