mirror of
https://github.com/neosubhamoy/neodlp.git
synced 2026-03-22 08:05:48 +05:30
refactor: revert back to cp again
This commit is contained in:
@@ -24,10 +24,6 @@
|
|||||||
"sql:allow-execute",
|
"sql:allow-execute",
|
||||||
"fs:allow-app-write",
|
"fs:allow-app-write",
|
||||||
"fs:allow-app-write-recursive",
|
"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",
|
"fs:allow-write-text-file",
|
||||||
"updater:default",
|
"updater:default",
|
||||||
"process:default",
|
"process:default",
|
||||||
|
|||||||
@@ -64,6 +64,11 @@
|
|||||||
"name": "powershell",
|
"name": "powershell",
|
||||||
"cmd": "powershell",
|
"cmd": "powershell",
|
||||||
"args": true
|
"args": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cp",
|
||||||
|
"cmd": "cp",
|
||||||
|
"args": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useKvPairs } from "@/helpers/use-kvpairs";
|
|||||||
import { useSettingsPageStatesStore } from "@/services/store";
|
import { useSettingsPageStatesStore } from "@/services/store";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { useLogger } from "@/helpers/use-logger";
|
import { useLogger } from "@/helpers/use-logger";
|
||||||
|
import { Command } from "@tauri-apps/plugin-shell";
|
||||||
|
|
||||||
interface FileMap {
|
interface FileMap {
|
||||||
source: string;
|
source: string;
|
||||||
@@ -54,12 +55,11 @@ export function useLinuxRegisterer() {
|
|||||||
if (isFlatpak) {
|
if (isFlatpak) {
|
||||||
for (const file of filesToCopyFlatpak) {
|
for (const file of filesToCopyFlatpak) {
|
||||||
const sourcePath = await join(resourceDirPath, file.source);
|
const sourcePath = await join(resourceDirPath, file.source);
|
||||||
const destinationDir = await join(homeDirPath, file.dir);
|
|
||||||
const destinationPath = await join(homeDirPath, file.destination);
|
const destinationPath = await join(homeDirPath, file.destination);
|
||||||
|
const command = Command.create('cp', [sourcePath, destinationPath]);
|
||||||
|
|
||||||
const dirExists = await fs.exists(destinationDir);
|
const output = await command.execute();
|
||||||
if (dirExists) {
|
if (output.code === 0) {
|
||||||
await fs.copyFile(sourcePath, destinationPath);
|
|
||||||
console.log(`File ${file.source} copied successfully to ${destinationPath}`);
|
console.log(`File ${file.source} copied successfully to ${destinationPath}`);
|
||||||
LOG.info("LINUX REGISTERER", `File ${file.source} copied successfully to ${destinationPath}`);
|
LOG.info("LINUX REGISTERER", `File ${file.source} copied successfully to ${destinationPath}`);
|
||||||
if (file.content) {
|
if (file.content) {
|
||||||
@@ -68,17 +68,8 @@ export function useLinuxRegisterer() {
|
|||||||
LOG.info("LINUX REGISTERER", `Content for ${file.source} written successfully to ${destinationPath}`);
|
LOG.info("LINUX REGISTERER", `Content for ${file.source} written successfully to ${destinationPath}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await fs.mkdir(destinationDir, { recursive: true })
|
console.error(`Failed to copy file ${file.source} to ${destinationPath}:`, output.stderr);
|
||||||
console.log(`Created dir ${destinationDir}`);
|
LOG.error("LINUX REGISTERER", `Failed to copy file ${file.source} to ${destinationPath}: ${output.stderr}`);
|
||||||
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}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user