Skip to content

Commit e43ff4f

Browse files
committed
fix delete file because trash always return undefined and doesn't raise error if no file
1 parent 5930247 commit e43ff4f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/pages/Project/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { openModal } from 'reducers/modals'
2424
import { addAlert } from 'reducers/alerts'
2525
import { setPreview } from 'actions/preview'
2626

27-
import { fileDialog, saveDialog, fsWriteFile } from 'helpers/fs'
27+
import { fileDialog, saveDialog, fsWriteFile, fileExists } from 'helpers/fs'
2828

2929
import Button from 'components/Button'
3030
import ButtonDropdown from 'components/Button/ButtonDropdown'
@@ -99,9 +99,13 @@ export default connect(
9999

100100
handleRemoveFile = async fileName => {
101101
try {
102-
if ((await trash(fileName)) === undefined) {
103-
throw new Error('No file was deleted')
102+
const trashed = await trash(fileName)
103+
const stillExists = await fileExists(fileName)
104+
105+
if (stillExists) {
106+
throw new Error('File still exists')
104107
}
108+
105109
this.props.addAlert('File successfully removed', 'success')
106110
} catch (e) {
107111
this.props.addAlert('Could not delete file', 'error')

0 commit comments

Comments
 (0)