Commit c1f8a458 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Fixed so that dbck can repair a truncated database.

parent 73149fff
Mon Mar 23 08:51:13 1992 Per Cederqvist (ceder@robin)
* dbck.c (truncated_texts): New variable.
* dbck.c (main): Increase modifications if truncated_texts is set.
* dbck-cache.c (init_cache): If the database is truncated or
severely damaged in the text-status part, just ignore the remaining
texts (and don't fail miserably).
Thu Mar 12 04:30:17 1992 Per Cederqvist (ceder@lysator) Thu Mar 12 04:30:17 1992 Per Cederqvist (ceder@lysator)
* membership.c (get_unread_confs): You must be logged in to use * membership.c (get_unread_confs): You must be logged in to use
......
/* /*
* $Id: dbck-cache.c,v 0.9 1992/02/26 18:45:15 ceder Exp $ * $Id: dbck-cache.c,v 0.10 1992/03/23 08:02:50 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association. * Copyright (C) 1991 Lysator Academic Computer Association.
* *
* This file is part of the LysKOM server. * This file is part of the LysKOM server.
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* Also save time as a time_t instead of a struct tm. * Also save time as a time_t instead of a struct tm.
*/ */
static char *rcsid = "$Id: dbck-cache.c,v 0.9 1992/02/26 18:45:15 ceder Exp $"; static char *rcsid = "$Id: dbck-cache.c,v 0.10 1992/03/23 08:02:50 ceder Exp $";
/* /*
...@@ -644,6 +644,7 @@ init_cache(void) ...@@ -644,6 +644,7 @@ init_cache(void)
FILE *fp = NULL; FILE *fp = NULL;
int i; int i;
extern int vflag; /* from dbck.c */ extern int vflag; /* from dbck.c */
extern Bool truncated_texts; /* from dbck.c */
new_text_file = NULL; new_text_file = NULL;
...@@ -748,8 +749,17 @@ init_cache(void) ...@@ -748,8 +749,17 @@ init_cache(void)
case '+': case '+':
text_arr[ i ] = alloc_text_stat(); text_arr[ i ] = alloc_text_stat();
if ( fparse_text_stat(fp, text_arr[ i ]) != OK ) if ( fparse_text_stat(fp, text_arr[ i ]) != OK )
restart_kom("init_cache(): fparse_text_stat failed. i == %d\n", {
i); /* Simply ignore the following texts. The cause of this
error might be that the file has been truncated (maybe
due to an overfull disk). */
log("init_cache(): fparse_text_stat failed for text %d.\n"
"All remaining texts are lost.\n", i);
next_text_num = i;
truncated_texts = TRUE;
}
break; break;
} }
} }
......
/* /*
* $Id: dbck.c,v 0.9 1992/02/26 18:45:13 ceder Exp $ * $Id: dbck.c,v 0.10 1992/03/23 08:02:42 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association. * Copyright (C) 1991 Lysator Academic Computer Association.
* *
* This file is part of the LysKOM server. * This file is part of the LysKOM server.
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* Author: Per Cederqvist. * Author: Per Cederqvist.
*/ */
static char *rcsid = "$Id: dbck.c,v 0.9 1992/02/26 18:45:13 ceder Exp $"; static char *rcsid = "$Id: dbck.c,v 0.10 1992/03/23 08:02:42 ceder Exp $";
#include <stdarg.h> #include <stdarg.h>
...@@ -46,6 +46,10 @@ static char *rcsid = "$Id: dbck.c,v 0.9 1992/02/26 18:45:13 ceder Exp $"; ...@@ -46,6 +46,10 @@ static char *rcsid = "$Id: dbck.c,v 0.9 1992/02/26 18:45:13 ceder Exp $";
#include <debug.h> #include <debug.h>
#include "dbck-cache.h" #include "dbck-cache.h"
/* This is set to TRUE if init_cache finds out that the last part of the
database is missing. */
Bool truncated_texts = FALSE;
char datafilename[1024]; /* Full pathname to the database file */ char datafilename[1024]; /* Full pathname to the database file */
char backupfilename[1024]; /* Full pathname to the backup file */ char backupfilename[1024]; /* Full pathname to the backup file */
char textfilename[1024]; char textfilename[1024];
...@@ -1246,6 +1250,10 @@ main (int argc, ...@@ -1246,6 +1250,10 @@ main (int argc,
init_data_base(); init_data_base();
errors = check_data_base(); errors = check_data_base();
if (truncated_texts == TRUE)
modifications++;
if ( iflag ) if ( iflag )
log("Total of %d error%s remains.\n", errors, errors == 1 ? "" : "s"); log("Total of %d error%s remains.\n", errors, errors == 1 ? "" : "s");
else if ( vflag && errors > 0 ) else if ( vflag && errors > 0 )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment