replugged icon indicating copy to clipboard operation
replugged copied to clipboard

Fix reloading asar addons without restarting Discord

Open asportnoy opened this issue 2 years ago • 5 comments

Electron caches asar files, which causes issues if you try to replace or update an addon while Discord is running. Our only workaround is to fully quit and restart Discord, which isn't ideal. We need some way to clear the cache.

asportnoy avatar Feb 19 '23 22:02 asportnoy

iirc electron caches asar files to memory

bop34 avatar Feb 19 '23 22:02 bop34

General solution: load addons with our own asar parsing instead of the automatic asar handling that Electron provides (use original-fs, available only in Electron, to access the unpatched version of Node's fs). The difference is that while Electron doesn't expose the asar cache, we have a bit more latitude if we reimplement asar loading.

Possible implementation approaches:

  • Use @electron/asar in main to load asar addons. The downside is that this also includes code to generate asar archives from folders. That's bloat.
  • Write our own barebones asar parser that supports the minimum features we need--read asar, cache files, clear cache.

In either case, it might be best to use a separate protocol for loading addons with our own asar handling. Our current protocol responds to queries with file paths; with our own asar handling, we would have to send raw data instead.

replugged.asar and Discord's stuff would continue to be loaded with Electron's default asar handling.

colin273 avatar Feb 19 '23 22:02 colin273

That's a pretty good idea. I'm willing to give it a shot, but I'm busy until Thursday. This would also close issue #373

bop34 avatar Feb 20 '23 16:02 bop34

Assigning to you for now

asportnoy avatar Feb 20 '23 17:02 asportnoy

That's a pretty good idea. I'm willing to give it a shot, but I'm busy until Thursday. This would also close issue #373

just reading the issue for fun and damn Feb 20 2023... Its Christmas now :3 just saying you forgot i guess

yofukashino avatar Dec 24 '23 23:12 yofukashino