From 8a75856461c64441e64df7ca7f78847a5459f11b Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Fri, 4 Feb 2005 00:44:49 +0000 Subject: [PATCH] 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! --- exec/newslink.js | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/exec/newslink.js b/exec/newslink.js index 29f06b814d..c5464a7b8a 100644 --- a/exec/newslink.js +++ b/exec/newslink.js @@ -263,13 +263,22 @@ var imported=0; var twitlist_fname = system.ctrl_dir + "twitlist.cfg"; 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); for(i in area) { - if(!socket.is_connected) { - print("Disconnected"); + if(!socket.is_connected) break; - } if(js.terminated || file_exists(stop_semaphore)) break; @@ -491,6 +500,18 @@ for(i in area) { 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 && ptr<=last_msg && !js.terminated @@ -498,11 +519,15 @@ for(i in area) { ;ptr++) { if(this.console!=undefined) 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)); rsp = readln(); 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; } body=""; @@ -762,6 +787,7 @@ for(i in area) { printf("!IMPORT %lu ERROR: %s\r\n", ptr, msgbase.last_error); } + ptr--; /* point to last requested article number */ if(ptr > last_msg) ptr = last_msg; import_ptr = ptr; @@ -781,8 +807,12 @@ for(i in area) { // load("binarydecoder.js",sub); } -writeln("quit"); -readln(); +if(!socket.is_connected) + print("!DISCONNECTED BY SERVER"); +else { + writeln("quit"); + readln(); +} delete socket; -- GitLab