making requested changes

This commit is contained in:
dante ruiz 2019-08-02 11:26:41 -07:00
parent 7ed13a2ba2
commit b9106b9ade
4 changed files with 26 additions and 35 deletions

View file

@ -4,8 +4,7 @@
@implementation DownloadLauncher
- (void) downloadLauncher:(NSString *)launcherUrl
{
- (void) downloadLauncher:(NSString*)launcherUrl {
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:launcherUrl]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
@ -22,10 +21,6 @@
}
-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didResumeAtOffset:(int64_t)fileOffset expectedTotalBytes:(int64_t)expectedTotalBytes {
// unused in this example
}
-(void)URLSession:(NSURLSession*)session downloadTask:(NSURLSessionDownloadTask*)downloadTask didFinishDownloadingToURL:(NSURL*)location {
NSLog(@"Did finish downloading to url");
NSError* error = nil;
@ -34,8 +29,7 @@
NSString* finalFilePath = [[[Launcher sharedLauncher] getDownloadPathForContentAndScripts] stringByAppendingPathComponent:destinationFileName];
NSURL *destinationURL = [NSURL URLWithString: [finalFilePath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]] relativeToURL: [NSURL URLWithString:@"file://"]];
NSLog(@"desintation %@", destinationURL);
if([fileManager fileExistsAtPath:[destinationURL path]])
{
if([fileManager fileExistsAtPath:[destinationURL path]]) {
[fileManager removeItemAtURL:destinationURL error:nil];
}
@ -52,14 +46,14 @@
[sharedLauncher displayErrorPage];
return;
}
NSLog(@"extracting domain content file");
BOOL extractionSuccessful = [sharedLauncher extractZipFileAtDestination:[sharedLauncher getDownloadPathForContentAndScripts] :[[sharedLauncher getDownloadPathForContentAndScripts] stringByAppendingString:destinationFileName]];
NSLog(@"extracting Launcher file");
BOOL extractionSuccessful = [sharedLauncher extractZipFileAtDestination:[sharedLauncher getDownloadPathForContentAndScripts] :[[sharedLauncher getDownloadPathForContentAndScripts] stringByAppendingString:@"HQ Launcher.zip"]];
if (!extractionSuccessful) {
[sharedLauncher displayErrorPage];
return;
}
NSLog(@"finished extracting content file");
NSLog(@"finished extracting Launcher file");
[[Launcher sharedLauncher] runAutoupdater];

View file

@ -1,8 +1,7 @@
#import "LauncherCommandlineArgs.h"
@implementation LauncherCommandlineArgs
+(NSDictionary*) arguments
{
+(NSDictionary*) arguments {
NSArray* arguments = [[NSProcessInfo processInfo] arguments];
if (arguments.count < 2)

View file

@ -12,10 +12,8 @@
}
@end
int main(int argc, char const* argv[])
{
if (argc < 3)
{
int main(int argc, char const* argv[]) {
if (argc < 3) {
NSLog(@"Error: wrong number of arguments");
return 0;
}
@ -25,9 +23,9 @@ int main(int argc, char const* argv[])
}
NSString* oldLauncher = [NSString stringWithUTF8String:argv[1]];
NSString* newLauncher = [NSString stringWithUTF8String:argv[2]];
NSURL* destinationUrl = [UpdaterHelper NSStringToNSURL:newLauncher];
NSFileManager* fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtURL:[UpdaterHelper NSStringToNSURL:oldLauncher] error:nil];
[fileManager moveItemAtURL: [UpdaterHelper NSStringToNSURL: newLauncher] toURL: [UpdaterHelper NSStringToNSURL:oldLauncher] error:nil];
[fileManager replaceItemAtURL:[UpdaterHelper NSStringToNSURL:oldLauncher] withItemAtURL:[UpdaterHelper NSStringToNSURL:newLauncher] backupItemName:nil options:NSFileManagerItemReplacementUsingNewMetadataOnly resultingItemURL:&destinationUrl error:nil];
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
NSURL* applicationURL = [UpdaterHelper NSStringToNSURL: [oldLauncher stringByAppendingString: @"/Contents/MacOS/HQ Launcher"]];
NSArray* arguments =@[];