From e43ff4f5390b0f4f57d8cc2a9c7dd602f50665a2 Mon Sep 17 00:00:00 2001 From: KMcB Date: Wed, 1 Apr 2020 20:01:33 +0200 Subject: [PATCH] fix delete file because trash always return undefined and doesn't raise error if no file --- src/pages/Project/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pages/Project/index.js b/src/pages/Project/index.js index 71c2bfcf..b9bd6f87 100644 --- a/src/pages/Project/index.js +++ b/src/pages/Project/index.js @@ -24,7 +24,7 @@ import { openModal } from 'reducers/modals' import { addAlert } from 'reducers/alerts' import { setPreview } from 'actions/preview' -import { fileDialog, saveDialog, fsWriteFile } from 'helpers/fs' +import { fileDialog, saveDialog, fsWriteFile, fileExists } from 'helpers/fs' import Button from 'components/Button' import ButtonDropdown from 'components/Button/ButtonDropdown' @@ -99,9 +99,13 @@ export default connect( handleRemoveFile = async fileName => { try { - if ((await trash(fileName)) === undefined) { - throw new Error('No file was deleted') + const trashed = await trash(fileName) + const stillExists = await fileExists(fileName) + + if (stillExists) { + throw new Error('File still exists') } + this.props.addAlert('File successfully removed', 'success') } catch (e) { this.props.addAlert('Could not delete file', 'error')