@setoelkahfi / svara / commits / f2ae7b3

fix: correct path used to copy file

Signed-off-by: mellobacon <mellodev@outlook.com>

mellobacon committed May 8, 2024 at 15:58 UTC f2ae7b34eaa634d70ecf0bda593b85a75a467d6e
1 file changed +4 -5
src/lib/File.ts
+4 -5
@@ -279,21 +279,20 @@ export async function readFile(path) {
279 export async function pasteFile(dest) {
280 const copied = await clipboard.readText();
281 const filename = copied.split(path.sep).pop();
282 - if (!await fs.exists(copied) || await fs.exists(`${dest}${path.sep}${filename}`))
282 + let newpath = `${dest}${path.sep}${filename}`;
283 + if (!await fs.exists(copied) || await fs.exists(newpath))
284 return
285 const fileData = await readFile(copied);
286
286 - if (dest === copied) return;
287 -
287 if (!await dialog.confirm(`Are you sure you want to copy "${filename}" from "./${copied.split(path.sep).pop()}" into "./${dest.split(path.sep).pop()}?"`, {title: "Nucleus: Move File"})) {
288 return;
289 }
290 try {
292 - await invoke("write_file", {path: dest, content: fileData.text, enc: fileData.encoding, hasBom: fileData.bom, spaces: fileData.spaces});
291 + await invoke("write_file", {path: newpath, content: fileData.text, enc: fileData.encoding, hasBom: fileData.bom, spaces: fileData.spaces});
292 } catch (e) {
293 error(`Cannot create file in path ${dest}. Error: ${e}`, {file: "File.ts", line: 287});
294 }
296 - addEditorTab(dest, filename);
295 + addEditorTab(newpath, filename);
296 }
297
298 export function checkValidFileName(input: string) {