You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
net_nntp: Add log for expired articles and allow interrupting expiration.
* Add articles to expire log when removed from history.
* Treat articles no longer in the spool as "expired" when rebuilding
history.
* Abort expiration if unload is pending.
* Run expiration in the background by default, so that
net_nntp can be unloaded while expiration is running.
The tests still run in the foreground for better synchronization
(and since we're not expiring large numbers of articles in the tests).
BBS_CLI_COMMAND(cli_expire, "news expire", 2, "Remove expired articles from the spool (optionally just for one group)", "news expire <group>"),
4853
+
BBS_CLI_COMMAND(cli_fgexpire, "news fgexpire", 2, "Remove expired articles from the spool (optionally just for one group), in foreground", "news expire <group>"),
@@ -350,7 +378,8 @@ int history_expire(const char *pattern)
350
378
351
379
if (should_expire_article(grp, now, arrival_time, expires)) {
352
380
intres=expire_article(grp, artnum);
353
-
if (!res) {
381
+
/* If we successfully expired it, or the article is no longer present in the spool, treat as expired */
382
+
if (!res|| !spool_article_exists(grp, artnum)) {
354
383
keep=0;
355
384
links_removed++;
356
385
}
@@ -372,16 +401,42 @@ int history_expire(const char *pattern)
372
401
/* Keep in history if article still exists in any groups, or if its age is less than min_history days (even if article may no longer be in any groups) */
373
402
if (groups_kept|| (min_history&& (arrival_time>history_cutoff))) {
/* No changes have been made yet, we can just keep the original file */
421
+
break;
422
+
}
423
+
424
+
startoffset=ftell(histfp);
425
+
fseek(histfp, 0, SEEK_END);
426
+
histsize=ftell(histfp);
427
+
fflush(newfp);
428
+
if (bbs_copy_file(fileno(histfp), fileno(newfp), (int) startoffset, (int) (histsize-startoffset)) <0) { /* Copy original headers, not including empty line */
429
+
error=1; /* If we failed to append the remainder of the file, don't discard the original history file */
430
+
}
431
+
break;
432
+
}
379
433
}
380
434
RWLIST_UNLOCK(&retention_patterns);
381
435
382
436
/* If needed, swap in the new history file and update pointers */
437
+
fclose(expirefp);
383
438
fclose(newfp);
384
-
if (total_removed>0) {
439
+
if (total_removed>0&& !error) {
385
440
bbs_verb(5, "Swapping in new history file (removed %d link%s, completely removed %d article%s)\n", links_removed, ESS(links_removed), total_removed, ESS(total_removed));
0 commit comments