Delete files

This commit is contained in:
Pascal Le Merrer 2026-01-28 23:34:16 +01:00
parent 30c5c785f3
commit c5176634c2

View file

@ -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);
});
});