From 42cb6a0b2d8bd52fa9f2534862f51949acc74fab Mon Sep 17 00:00:00 2001 From: khanhduytran0 Date: Mon, 12 Feb 2024 06:46:26 +0700 Subject: [PATCH] Fix[MDCL]: regression in handling offline state --- Natives/MinecraftResourceDownloadTask.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Natives/MinecraftResourceDownloadTask.m b/Natives/MinecraftResourceDownloadTask.m index d4923513d9..ad14d8d544 100644 --- a/Natives/MinecraftResourceDownloadTask.m +++ b/Natives/MinecraftResourceDownloadTask.m @@ -79,6 +79,10 @@ - (void)downloadVersionMetadata:(NSDictionary *)version success:(void (^)())succ void(^completionBlock)(void) = ^{ self.verMetadata = parseJSONFromFile(path); + if (!self.verMetadata) { + [self finishDownloadWithErrorString:@"Downloaded version json was not found"]; + return; + } if (self.verMetadata[@"inheritsFrom"]) { NSMutableDictionary *inheritsFromDict = parseJSONFromFile([NSString stringWithFormat:@"%1$s/versions/%2$@/%2$@.json", getenv("POJAV_GAME_DIR"), self.verMetadata[@"inheritsFrom"]]); if (inheritsFromDict) { @@ -97,7 +101,7 @@ - (void)downloadVersionMetadata:(NSDictionary *)version success:(void (^)())succ [self finishDownloadWithErrorString:@"Local version json was not found"]; } else if (json[@"inheritsFrom"]) { version = (id)[MinecraftResourceUtils findVersion:json[@"inheritsFrom"] inList:remoteVersionList]; - path = [NSString stringWithFormat:@"%1$s/versions/%2$@/%2$@.json", getenv("POJAV_GAME_DIR"), version[@"id"]]; + path = [NSString stringWithFormat:@"%1$s/versions/%2$@/%2$@.json", getenv("POJAV_GAME_DIR"), json[@"inheritsFrom"]]; } else { completionBlock(); return; @@ -253,7 +257,7 @@ - (BOOL)checkAccessWithDialog:(BOOL)show { // Check SHA of the file - (BOOL)checkSHAIgnorePref:(NSString *)sha forFile:(NSString *)path altName:(NSString *)altName logSuccess:(BOOL)logSuccess { - if (sha == nil) { + if (sha.length == 0) { // When sha = skip, only check for file existence BOOL existence = [NSFileManager.defaultManager fileExistsAtPath:path]; if (existence) {