sparkle-project / Sparkle

A software update framework for macOS
https://sparkle-project.org
Other
7.34k stars 1.04k forks source link

Intermediate process before asking admin password #2525

Closed buzunboy closed 5 months ago

buzunboy commented 5 months ago

Summary

Possible Fix

- (void)downloadDriverDidDownloadUpdate:(SPUDownloadedUpdate *)downloadedUpdate
{
   ... 
    _resumableUpdate = downloadedUpdate;

    if (updater != nil && [updaterDelegate respondsToSelector:@selector(updater:shouldStartExtracting:invocation:)]) {
        [updaterDelegate updater:updater shouldStartExtracting:_updateItem invocation:^{
            dispatch_async(dispatch_get_main_queue(), ^{
                [self extractUpdate:downloadedUpdate];
            });
        }];
    } else {
        [self extractUpdate:downloadedUpdate];
    }
}

and with new method in the SPUUpdaterDelegate.h:

- (void)updater:(SPUUpdater *)updater shouldStartExtracting:(SUAppcastItem *)item invocation:(void (^)(void))reply;

So flow would be like:

  1. User/App calls SPUUpdater.checkForUpdates
  2. Sparkle calls func showUpdateFound(with appcastItem: SUAppcastItem, state: SPUUserUpdateState, reply: @escaping (SPUUserUpdateChoice) -> Void)
  3. App automatically replies with reply(.install)
  4. Sparkle starts & finishes the download, before extracting checks the implementation of updater:shouldStartExtracting:invocation: and only continues to extract if it's responded and invocation is called by the app.

I can create a pull request as well, posted as an issue to discuss first.

Thanks and best

Version

2.5.2, 2.6.0