From c5176634c281112f7c993ffe2a895c24c6d559d4 Mon Sep 17 00:00:00 2001 From: Pascal Le Merrer Date: Wed, 28 Jan 2026 23:34:16 +0100 Subject: [PATCH] Delete files --- src/wrapper.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/wrapper.js b/src/wrapper.js index a9f8d21..6113039 100644 --- a/src/wrapper.js +++ b/src/wrapper.js @@ -196,3 +196,26 @@ app.ports.openFile.subscribe(function (filePath) { }); }); +// Delete a file +app.ports.removeFile.subscribe(function (filePath) { + + const lastSeparatorIndex = filePath.lastIndexOf(separator); + const directoryName = filePath.substring(0, lastSeparatorIndex + 1); + const fileName = filePath.substring(lastSeparatorIndex + 1); + + getFileMetadata(directoryName, fileName).then((fileInfo)=> { + fs.remove(filePath) + .then(() => { + app.ports.fileRemoved.send(fileInfo); + }) + .catch((msg) => { + console.error(msg); + app.ports.receiveError.send(msg); + }); + }) + .catch((msg) => { + console.error(msg); + app.ports.receiveError.send(msg); + }); + +});