mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Reload NSBundle cache on its info plist dictionary
We reload the info dictionary before we start off an update driver. This is so that we have the latest up to date information for the bundle.
This commit is contained in:
1 parent
411c0ac8bd
commit
52fd21e119
3 files changed
+26
-6
No files matched your search
Vendored
+5
@@ -12,6 +12,11 @@
|
||||
@property (strong, readonly) NSBundle *bundle;
|
||||
|
||||
- (instancetype)initWithBundle:(NSBundle *)aBundle;
|
||||
|
||||
// Invalidates the info dictionary cache
|
||||
// This is not thread safe
|
||||
- (void)reloadInfoDictionary;
|
||||
|
||||
@property (readonly, copy) NSString *bundlePath;
|
||||
@property (readonly, copy) NSString *name;
|
||||
@property (readonly, copy) NSString *version;
|
||||
|
||||
Vendored
+17
-6
@@ -28,6 +28,7 @@
|
||||
@property (strong, readwrite) NSBundle *bundle;
|
||||
@property (copy) NSString *defaultsDomain;
|
||||
@property (assign) BOOL usesStandardUserDefaults;
|
||||
@property (nonatomic) NSDictionary *infoDictionary;
|
||||
|
||||
@end
|
||||
|
||||
@@ -36,6 +37,7 @@
|
||||
@synthesize bundle;
|
||||
@synthesize defaultsDomain;
|
||||
@synthesize usesStandardUserDefaults;
|
||||
@synthesize infoDictionary = _infoDictionary;
|
||||
|
||||
- (instancetype)initWithBundle:(NSBundle *)aBundle
|
||||
{
|
||||
@@ -46,8 +48,10 @@
|
||||
if (![self.bundle bundleIdentifier]) {
|
||||
SULog(@"Error: the bundle being updated at %@ has no %@! This will cause preference read/write to not work properly.", self.bundle, kCFBundleIdentifierKey);
|
||||
}
|
||||
|
||||
_infoDictionary = aBundle.infoDictionary;
|
||||
|
||||
self.defaultsDomain = [self.bundle objectForInfoDictionaryKey:SUDefaultsDomainKey];
|
||||
self.defaultsDomain = [self objectForInfoDictionaryKey:SUDefaultsDomainKey];
|
||||
if (!self.defaultsDomain) {
|
||||
self.defaultsDomain = [self.bundle bundleIdentifier];
|
||||
}
|
||||
@@ -59,6 +63,13 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
// NSBundles always cache the info dictionary, even if you create a new NSBundle instance, but we sometimes want to reload it
|
||||
// in case the bundle changes or is updated
|
||||
- (void)reloadInfoDictionary
|
||||
{
|
||||
CFDictionaryRef infoDictionary = CFBundleCopyInfoDictionaryInDirectory((CFURLRef)self.bundle.bundleURL);
|
||||
self.infoDictionary = CFBridgingRelease(infoDictionary);
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self bundlePath]]; }
|
||||
|
||||
@@ -75,7 +86,7 @@
|
||||
name = [self objectForInfoDictionaryKey:@"SUBundleName"];
|
||||
if (name && name.length > 0) return name;
|
||||
|
||||
name = [self.bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||
name = [self objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||
if (name && name.length > 0) return name;
|
||||
|
||||
name = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey];
|
||||
@@ -96,7 +107,7 @@
|
||||
|
||||
- (NSString *)_version
|
||||
{
|
||||
NSString *version = [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
NSString *version = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
return ([self isValidVersion:version] ? version : nil);
|
||||
}
|
||||
|
||||
@@ -112,7 +123,7 @@
|
||||
|
||||
- (NSString * _Nonnull)displayVersion
|
||||
{
|
||||
NSString *shortVersionString = [self.bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||
NSString *shortVersionString = [self objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||
if (shortVersionString)
|
||||
return shortVersionString;
|
||||
else
|
||||
@@ -129,7 +140,7 @@
|
||||
- (NSString *_Nullable)publicDSAKey
|
||||
{
|
||||
// Maybe the key is just a string in the Info.plist.
|
||||
NSString *key = [self.bundle objectForInfoDictionaryKey:SUPublicDSAKeyKey];
|
||||
NSString *key = [self objectForInfoDictionaryKey:SUPublicDSAKeyKey];
|
||||
if (key) {
|
||||
return key;
|
||||
}
|
||||
@@ -149,7 +160,7 @@
|
||||
|
||||
- (id)objectForInfoDictionaryKey:(NSString *)key
|
||||
{
|
||||
return [self.bundle objectForInfoDictionaryKey:key];
|
||||
return [self.infoDictionary objectForKey:key];
|
||||
}
|
||||
|
||||
- (BOOL)boolForInfoDictionaryKey:(NSString *)key
|
||||
|
||||
Vendored
+4
@@ -475,6 +475,10 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
|
||||
// Reload our host bundle information in case its current cache is out of date
|
||||
// We could have updated the bundle before for example without terminating this updater process
|
||||
[self.host reloadInfoDictionary];
|
||||
|
||||
// Because an application can change the configuration (eg: the feed url) at any point, we should always check if it's valid
|
||||
NSError *configurationError = nil;
|
||||
|
||||
Reference in new issue
Block a user