OS.js icon indicating copy to clipboard operation
OS.js copied to clipboard

Failure to cancel file upload correctly

Open maryam4s26 opened this issue 11 months ago • 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.

maryam4s26 avatar Mar 06 '24 21:03 maryam4s26

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()
  }
}

andersevenrud avatar Mar 06 '24 21:03 andersevenrud