Crypter-File-Transfer / Crypter

A Blazor WASM web application that offers end-to-end encrypted file and message transfer using Libsodium, Entity Framework, Hangfire, Docker, NUnit, and Mailkit.
https://www.crypter.dev
GNU Affero General Public License v3.0
37 stars 15 forks source link

Only register the service worker when downloading a file #719

Closed Jack-Edwards closed 1 week ago

Jack-Edwards commented 2 months ago

To work around the Chromium issues linked below, this PR ensures the "download" service worker is only present as a file is being downloaded. Otherwise, a "no op" service worker is made active.

The reason for using a "no op" service worker, instead of simply unregistering the "download" service worker, is unregistration still requires the tab to be reloaded or a navigation to occur before the unregistered service worker stops working. Replacing the service worker with one that does not have a "fetch" event handler works instantaneously and doesn't seem to interfere with file uploads.

Still not an ideal solution, as simultaneous upload and download will probably break, but the UI really doesn't lend to that usage anyway.

https://issues.chromium.org/issues/339788214 https://issues.chromium.org/issues/41360286