os-js/OS.js

Failure to cancel file upload correctly

Opened this issue · 1 comments

Hi @andersevenrud
I have a problem.
If I click the cancel button while uploading the file, the file upload dialog closes but the upload process is not completely canceled and the file is finally uploaded.

Sadly, there is no direct HTTP request abort available in the VFS at the moment.

It should be fairly easy to implement though, at least for file uploads.

  1. The options in the writefile() function needs to accept abort: AbortController
  2. Which is then passed on to the system adapter writefile()
  3. Which is again passed on to the HTTP request abstraction
  4. Then the file manager can trigger the abort on dialog cancel

const aborter = new AbortController()

vfs.writefile({ /* */ }, file, {
  abort: aborter
})

// In a dialog callback
(btn) => {
  if (btn === 'cancel') {
    aborter.abort()
  }
}