From efe2a7db68f0f253fba1ba07966a668c42015d39 Mon Sep 17 00:00:00 2001 From: Antonin Hildebrand Date: Wed, 3 Jul 2013 19:21:46 -0700 Subject: [PATCH] do NOT check for updates when network is not available --- SUUpdater.m | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/SUUpdater.m b/SUUpdater.m index 87a66833..0754836b 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -239,7 +239,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; SCNetworkConnectionFlags flags = 0; - BOOL isNetworkReachable = YES; + BOOL isNetworkReachable = NO; // Don't perform automatic checks on unconnected laptops or dial-up connections that aren't online: NSMutableDictionary* theDict = [NSMutableDictionary dictionary]; @@ -250,20 +250,21 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault Boolean reachabilityResult = NO; // If the feed's using a file:// URL, we won't be able to use reachability. if (reachability != NULL) { + reachabilityResult = YES; SCNetworkReachabilityGetFlags(reachability, &flags); CFRelease(reachability); } if( reachabilityResult ) { + BOOL needsConnection = ((flags & kSCNetworkFlagsConnectionRequired) != 0); BOOL reachable = (flags & kSCNetworkFlagsReachable) == kSCNetworkFlagsReachable; - BOOL automatic = (flags & kSCNetworkFlagsConnectionAutomatic) == kSCNetworkFlagsConnectionAutomatic; BOOL local = (flags & kSCNetworkFlagsIsLocalAddress) == kSCNetworkFlagsIsLocalAddress; - //NSLog(@"reachable = %s, automatic = %s, local = %s", (reachable?"YES":"NO"), (automatic?"YES":"NO"), (local?"YES":"NO")); + NSLog(@"reachable = %s, needsConnection = %s, local = %s", (reachable?"YES":"NO"), (needsConnection?"YES":"NO"), (local?"YES":"NO")); - if( !(reachable || automatic || local) ) - isNetworkReachable = NO; + if (local || (reachable && !needsConnection)) + isNetworkReachable = YES; } // If the network's not reachable, we pass a nil driver into checkForUpdatesWithDriver, which will then reschedule the next update so we try again later.