Skip to content

Commit

Permalink
Better error flow handling (overload dealing, w/ htmlCache), bugfix f…
Browse files Browse the repository at this point in the history
…or updating page when server non-400OK

For the second point, possibly, now, retries will happen (requires further testing to confirm for now)
  • Loading branch information
Nico committed Jun 21, 2023
1 parent df52a6c commit 00480f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
19 changes: 11 additions & 8 deletions crero-script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
var uaxhttpattempt=0;


var page_init;
var album_displayed=0;
var overload_track_counter=NaN;
Expand Down Expand Up @@ -534,7 +537,6 @@ function update_ajax_body(http_url_target, comesfrominfiniteloop){
var parameters='';
var arg='';
set_overload_track_counter(0);
var uaxhttpattempt=0;

//set_page_init(false);

Expand Down Expand Up @@ -658,13 +660,11 @@ function update_ajax_body(http_url_target, comesfrominfiniteloop){
if (infiniteloop){init_page();}
}
else {
uaxhttpattempt++;
update_twirling_message('The server replied with a non OK code: '+this.status+' ; retrying, retry is '+uaxhttpattempt);
this.abort();
//update_ajax_body(http_url_target, comesfrominfiniteloop);
this.open();
this.send();
}
uaxhttpattempt++;
update_twirling_message('The server replied with a non OK code: '+this.status+' ; retrying, retry is '+uaxhttpattempt);
this.abort();
update_ajax_body(http_url_target, comesfrominfiniteloop);
}
}
}
//console.log(finalurl);
Expand Down Expand Up @@ -1179,6 +1179,9 @@ function set_creroypservices(cyparg){
function init_page() {
radiomsg='fetching data...';

uaxhttpattempt=0;


if (radioIntervalFunc==null){
radioIntervalFunc=window.setInterval(update_radio_nowplaying, 4500);
}
Expand Down
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,7 @@ function checkOverload(allowRecursive){
if (this.readyState == 4 && this.status == 200) {
dl_queried = parseInt(this.responseText);

if ((dl_queried!=parseInt(-1))&&(parseInt(get_dl_album_count())!=dl_queried)){
if (Number.isInteger(overload_track_counter)&&(dl_queried!=parseInt(-1))&&(parseInt(get_dl_album_count())!=dl_queried)){
set_album_error(true);

set_dl_album_count(dl_queried);
Expand All @@ -3171,7 +3171,7 @@ function checkOverload(allowRecursive){
if (this.readyState == 4 && this.status == 200) {
str_queried = parseInt(this.responseText);

if ((str_queried!=parseInt(-1))&&(parseInt(get_str_album_count())!=str_queried)){
if (Number.isInteger(overload_track_counter)&&(str_queried!=parseInt(-1))&&(parseInt(get_str_album_count())!=str_queried)){

set_album_error(true);

Expand Down

0 comments on commit 00480f9

Please sign in to comment.