Skip to content
Snippets Groups Projects
Commit 8a758564 authored by rswindell's avatar rswindell
Browse files

Bugfix: If aborted due to disconnection, the import pointer would be off by one

causing the next article to not be imported the next time newslink ran.
Use XOVER to get article headers (if supported on server). This reduces the
likelihood of requesting a bad article number which some servers now consider
worthy of disconnection!
parent d40a3001
No related branches found
No related tags found
No related merge requests found
...@@ -263,13 +263,22 @@ var imported=0; ...@@ -263,13 +263,22 @@ var imported=0;
var twitlist_fname = system.ctrl_dir + "twitlist.cfg"; var twitlist_fname = system.ctrl_dir + "twitlist.cfg";
var use_twitlist = file_exists(twitlist_fname); var use_twitlist = file_exists(twitlist_fname);
function article_listed(list, article)
{
var i;
for(i in list)
if(list[i]==article)
return(list.splice(i,1));
return(false);
}
printf("Scanning %lu message bases...\r\n",area.length); printf("Scanning %lu message bases...\r\n",area.length);
for(i in area) { for(i in area) {
if(!socket.is_connected) { if(!socket.is_connected)
print("Disconnected");
break; break;
}
if(js.terminated || file_exists(stop_semaphore)) if(js.terminated || file_exists(stop_semaphore))
break; break;
...@@ -491,6 +500,18 @@ for(i in area) { ...@@ -491,6 +500,18 @@ for(i in area) {
ptr++; ptr++;
} }
delete article_list;
if(ptr<=last_msg) {
writeln(format("XOVER %u-%u", ptr, last_msg));
if(parseInt(readln())==224) {
printf("Getting headers for articles %u through %u\r\n", ptr, last_msg);
article_list = new Array();
while((rsp=readln())!='.' && rsp)
article_list.push(parseInt(rsp));
printf("%u new articles\r\n", article_list.length);
}
}
for(;socket.is_connected for(;socket.is_connected
&& ptr<=last_msg && ptr<=last_msg
&& !js.terminated && !js.terminated
...@@ -498,11 +519,15 @@ for(i in area) { ...@@ -498,11 +519,15 @@ for(i in area) {
;ptr++) { ;ptr++) {
if(this.console!=undefined) if(this.console!=undefined)
console.line_counter = 0; console.line_counter = 0;
if(article_list && !article_listed(article_list,ptr))
continue;
printf("Retrieving article: %u\r\n", ptr);
writeln(format("ARTICLE %lu",ptr)); writeln(format("ARTICLE %lu",ptr));
rsp = readln(); rsp = readln();
if(rsp==null || rsp[0]!='2') { if(rsp==null || rsp[0]!='2') {
if(debug) printf("!ARTICLE %lu ERROR: %s\r\n",ptr,rsp);
printf("!ARTICLE %lu ERROR: %s\r\n",ptr,rsp);
continue; continue;
} }
body=""; body="";
...@@ -762,6 +787,7 @@ for(i in area) { ...@@ -762,6 +787,7 @@ for(i in area) {
printf("!IMPORT %lu ERROR: %s\r\n", ptr, msgbase.last_error); printf("!IMPORT %lu ERROR: %s\r\n", ptr, msgbase.last_error);
} }
ptr--; /* point to last requested article number */
if(ptr > last_msg) if(ptr > last_msg)
ptr = last_msg; ptr = last_msg;
import_ptr = ptr; import_ptr = ptr;
...@@ -781,8 +807,12 @@ for(i in area) { ...@@ -781,8 +807,12 @@ for(i in area) {
// load("binarydecoder.js",sub); // load("binarydecoder.js",sub);
} }
writeln("quit"); if(!socket.is_connected)
readln(); print("!DISCONNECTED BY SERVER");
else {
writeln("quit");
readln();
}
delete socket; delete socket;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment