1
1
mirror of https://github.com/neosubhamoy/neodlp.git synced 2026-03-22 09:05:49 +05:30

refactor: use cp instead of fs api on flatpak

This commit is contained in:
2026-02-26 10:20:33 +05:30
Verified
parent 705e819fe7
commit a7d726c3d3
2 changed files with 24 additions and 3 deletions

View File

@@ -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;
@@ -41,12 +42,22 @@ export function useLinuxRegisterer() {
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 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}`);
} 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}`);
}
// const dirExists = await fs.exists(destinationDir);
// if (dirExists) {
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}`);
// 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}`);
// } else {
// await fs.mkdir(destinationDir, { recursive: true })
// console.log(`Created dir ${destinationDir}`);