speed up plugin installation with native ZIP extraction - #2715
speed up plugin installation with native ZIP extraction#2715codewithchai0605 wants to merge 5 commits into
Conversation
Greptile SummaryThis PR moves plugin ZIP extraction into the native Android bridge and activates installations through staging-directory swaps.
Confidence Score: 4/5The interrupted-update state misclassification should be fixed before merging because a subsequent plugin load failure can remove both the recovered installation and its backup. Native recovery can restore a missing destination after JavaScript has recorded it as a fresh install, causing the error path to delete the plugin, while interrupted staging directories can also accumulate indefinitely. Files Needing Attention: src/lib/installPlugin.js and src/plugins/pluginContext/src/android/Tee.java Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Download and validate ZIP in JavaScript] --> B[Write ZIP to cache]
B --> C[Invoke Tee.extractPluginArchive]
C --> D[Restore interrupted backup]
D --> E[Extract into staging directory]
E --> F[Move current plugin to backup]
F --> G[Move staging to destination]
G --> H[Delete backup]
H --> I[Load installed plugin]
I -->|Load error on recovered update| J[JavaScript cleanup may delete destination]
Reviews (1): Last reviewed commit: "perf: reduce native plugin extraction ov..." | Re-trigger Greptile |
| } | ||
| assertSafePluginId(id); | ||
| pluginDir = Url.join(PLUGIN_DIR, id); | ||
| pluginWasInstalled = await fsOperation(pluginDir).exists(); |
There was a problem hiding this comment.
Recovered update misclassified as fresh
When an interrupted update leaves only a backup, pluginWasInstalled is recorded as false before native recovery restores that backup. If the subsequent plugin load fails, the catch block treats the recovered update as a fresh installation and deletes the activated directory after its backup has been removed, leaving the plugin uninstalled.
Knowledge Base Used: Plugin System
| staging = new File( | ||
| parent, | ||
| "." + destination.getName() + ".install-" + UUID.randomUUID() | ||
| ); |
There was a problem hiding this comment.
Interrupted staging directories accumulate
If Android terminates the process after creating a UUID-suffixed .install-* directory, the finally cleanup never runs and restart recovery scans only .backup-* directories. These abandoned extractions can retain hundreds of megabytes each and consume application storage over time.
Knowledge Base Used: Plugin System
Summary
This PR improves plugin installation performance, especially for plugins containing many small files such as file/folder icon providers.
The previous installer extracted archive entries in JavaScript with a concurrency limit of 2. This caused significant overhead from repeated JS-to-native filesystem calls.
This change moves archive extraction to native Android code and writes files directly from the ZIP archive.
Changes
ZipFile.