Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/plugins/catalog/plugin-auto-updater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,16 @@ describe('plugin auto-update', () => {
expect(offline.install).not.toHaveBeenCalled()
})

it('installs nothing when auto-update is turned off while the pass is in flight', async () => {
const options: Parameters<typeof setup>[0] = { officialCatalog: true }
options.killListRefresh = async () => {
options.enabled = false
}
const { updater, install } = setup(options)
await updater.run()
expect(install).not.toHaveBeenCalled()
})

it('installs at once from an official catalog and logs it for hosts without a UI', async () => {
const info = vi.spyOn(console, 'info').mockImplementation(() => undefined)
const { updater, install } = setup({ officialCatalog: true })
Expand Down
6 changes: 5 additions & 1 deletion src/main/plugins/catalog/plugin-auto-updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ export class PluginAutoUpdater {
const outcome: PluginCatalogInstallOutcome = await installCatalogReleaseWithApproval({
pluginKey: plugin.pluginKey,
pluginService,
install: () => installer.install(preview, { requireInstalled: true }),
// Why at the last await: the user may turn auto-update off while this pass waits.
install: async () =>
this.options.isEnabled()
? installer.install(preview, { requireInstalled: true })
: { ok: false, error: 'automatic updates were turned off' },
approve: this.options.approve
})
if (!outcome.ok) {
Expand Down
Loading