Delete files
This commit is contained in:
parent
30c5c785f3
commit
c5176634c2
1 changed files with 23 additions and 0 deletions
|
|
@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue