Skip to content

Commit

Permalink
Fix[MDCL]: regression in handling offline state
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhduytran0 committed Feb 11, 2024
1 parent 805b4c8 commit 42cb6a0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Natives/MinecraftResourceDownloadTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 42cb6a0

Please sign in to comment.