works_for_me
Volker Birk 3 years ago
parent fa28fa7bfe
commit 5b620a5547

@ -34,7 +34,7 @@
- (void)updateAll:(NSTimer*)timer;
/// update software described by config file
- (void)updateWithFile:(NSString*)configFile;
- (void)updateWithFile:(NSString*)configFile error:(NSError **)err;
/// update a product from URL of update server
- (void)update:(NSString*)name usingUrl:(NSString*)url;

@ -47,16 +47,19 @@ DownloadNotification _subscriber = nil;
NSString *configFile;
while (dirEnum && (configFile = [dirEnum nextObject])) {
if ([[configFile pathExtension] isEqualToString: @"plist"]) {
[self updateWithFile:configFile];
NSError *err = nil;
[self updateWithFile:[NSString stringWithFormat:@"%@/%@", self.configPath, configFile] error:&err];
}
}
}
- (void)updateWithFile:(NSString*)configFile
- (void)updateWithFile:(NSString*)configFile error:(NSError **)err
{
NSInputStream *is = [NSInputStream inputStreamWithFileAtPath:configFile];
NSError* err = nil;
NSDictionary* plist = [NSPropertyListSerialization propertyListWithStream:is options:NSPropertyListImmutable format:nil error:&err];
[is open];
NSDictionary* plist = [NSPropertyListSerialization propertyListWithStream:is options:NSPropertyListMutableContainers format:nil error:err];
[is close];
if (plist) {
NSString* name = [plist objectForKey:@"name"];
NSString* url = [plist objectForKey:@"url"];
@ -65,7 +68,7 @@ DownloadNotification _subscriber = nil;
}
}
else if (err) {
NSLog(@"pEpMacOSAdapter: %@ %@ %@ %@", err.localizedDescription, err.localizedFailureReason, err.localizedRecoveryOptions, err.localizedRecoverySuggestion);
NSLog(@"pEpMacOSAdapter: %@ %@ %@ %@", (*err).localizedDescription, (*err).localizedFailureReason, (*err).localizedRecoveryOptions, (*err).localizedRecoverySuggestion);
}
}

@ -32,7 +32,13 @@ pEpUpdater* updater;
}
- (void)testUpdateWithFile {
[updater updateWithFile:[[NSBundle bundleForClass:[pEpUpdater_Test class]] pathForResource:@"test" ofType:@"plist"]];
NSError *err = nil;
[updater updateWithFile:[NSString stringWithFormat:@"%@/%@", updater.configPath, @"test.plist"] error:&err];
XCTAssertNil(err);
}
- (void)testUpdateAll {
[updater updateAll:nil];
}
/*

Loading…
Cancel
Save