Update 'update.pl'

Proper fetching of index2.json as part of the update process. Also proper rotating and re indexing of index.json as part of the update check.
This commit is contained in:
kake26 2023-01-05 18:36:01 +00:00
parent 75e8629de2
commit c35742a24d

View file

@ -85,13 +85,24 @@ sub do_update ($mod,$ver,$author) {
# print "Update info $mod $ver $author\n";
}
sub update_files () {
# This is triggered when mod updates are detected
system("rm index.json");
system("cp index2.json index.json");
system("rm mods");
undef(%conf);
&get_ready();
return;
}
# Maybe get ready and check update should be called every time
if (-e "mods"){
# load data
print "Loading data\n";
$conf = retrieve('mods');
get_file();
chk_update();
update_files();
}else{
get_ready();
# chk_update expects a hash retrived from storables so program needs to be run again after this