The swiss army knife of lossless video/audio editing
Ask for delete if trash fails #298
Mikael Finstad6a8d74f88168
diff --git a/src/App.jsx b/src/App.jsxindex 345506f1..9d7fd070 100644--- a/src/App.jsx+++ b/src/App.jsx@@ -872,15 +872,29 @@ const App = memo(() => {// eslint-disable-next-line no-alertif (working || !window.confirm(`${i18n.t('Are you sure you want to move the source file to trash?')} ${filePath}`)) return;+ // We can use variables like filePath and html5FriendlyPath, even after they are reset because react setState is async+ resetState();+try {setWorking(true);await trash(filePath);+ // throw new Error('test');if (html5FriendlyPath) await trash(html5FriendlyPath);} catch (err) {- toast.fire({ icon: 'error', title: `${i18n.t('Failed to trash source file:')} ${err.message}` });+ console.warn('Failed to trash', err);+ const { value } = await Swal.fire({+ icon: 'warning',+ text: i18n.t('Unable to move source file to trash. Do you want to permanently delete it?'),+ confirmButtonText: 'Permanently delete',+ showCancelButton: true,+ });+ if (value) {+ await unlink(filePath).catch(console.warn);+ if (html5FriendlyPath) await unlink(html5FriendlyPath).catch(console.warn);+ }} finally {- resetState();+ setWorking(false);}}, [filePath, html5FriendlyPath, resetState, working]);