defer updating content.map until shared content is succesfully installed

This commit is contained in:
w3irDv 2024-05-26 18:59:29 +02:00
parent bc177f4998
commit 2d8980ed7e

View File

@ -322,13 +322,14 @@ bool Wad::InstallContents(const char *installpath)
// Install content // Install content
if(content->type == 0x8001) { if(content->type == 0x8001) {
// shared content // shared content
int result = UpdateContentMap(installpath, content, filepath); int result = CheckContentMap(installpath, content, filepath);
if(result == 1) // exists already, skip file if(result == 1) // exists already, skip file
continue; continue;
else if(result < 0) // failure else if(result < 0) // failure
return false; return false;
// else it does not exist...install it // else it does not exist...install it
snprintf(filepath, sizeof(filepath), "%s/shared1/%08x.app", installpath, (unsigned int)content_map_size);
} }
else { else {
// private content // private content
@ -419,6 +420,16 @@ bool Wad::InstallContents(const char *installpath)
ShowError(tr("File read/write error.")); ShowError(tr("File read/write error."));
return false; return false;
} }
if(content->type == 0x8001) {
// shared content installed ok. It's time to update content.map
int result = UpdateContentMap(installpath, content, filepath);
if(result == 1) // exists already, skip file
continue;
else if(result < 0) // failure
return false;
}
} }
return true; return true;
@ -482,8 +493,6 @@ int Wad::UpdateContentMap(const char *installpath, tmd_content *content, char *f
if(!WriteFile(filepath, content_map, content_map_size * sizeof(map_entry_t))) if(!WriteFile(filepath, content_map, content_map_size * sizeof(map_entry_t)))
return -1; return -1;
snprintf(filepath, 1024, "%s/shared1/%08x.app", installpath, (unsigned int)next_entry);
return 0; return 0;
} }