summaryrefslogtreecommitdiffabout
path: root/src/recover.c
Unidiff
Diffstat (limited to 'src/recover.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/recover.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/recover.c b/src/recover.c
index d6d4ff9..721c23f 100644
--- a/src/recover.c
+++ b/src/recover.c
@@ -309,21 +309,36 @@ run_recovery (GDBM_FILE dbf, GDBM_FILE new_dbf, gdbm_recovery *rcvr, int flags)
309 309
310 data.dptr = dptr + key.dsize; 310 data.dptr = dptr + key.dsize;
311 data.dsize = dbf->bucket->h_table[i].data_size; 311 data.dsize = dbf->bucket->h_table[i].data_size;
312 312
313 if (gdbm_store (new_dbf, key, data, GDBM_INSERT) != 0) 313 if (gdbm_store (new_dbf, key, data, GDBM_INSERT) != 0)
314 { 314 {
315 if (flags & GDBM_RCVR_ERRFUN) 315 switch (gdbm_last_errno (new_dbf))
316 rcvr->errfun (rcvr->data, 316 {
317 _("fatal: can't store element %d:%d (%lu:%d): %s"), 317 case GDBM_CANNOT_REPLACE:
318 bucket_dir, i, 318 rcvr->duplicate_keys++;
319 (unsigned long) dbf->bucket->h_table[i].data_pointer, 319 if (flags & GDBM_RCVR_ERRFUN)
320 dbf->bucket->h_table[i].key_size 320 rcvr->errfun (rcvr->data,
321 _("ignoring duplicate key %d:%d (%lu:%d)"),
322 bucket_dir, i,
323 (unsigned long) dbf->bucket->h_table[i].data_pointer,
324 dbf->bucket->h_table[i].key_size
325 + dbf->bucket->h_table[i].data_size);
326 break;
327
328 default:
329 if (flags & GDBM_RCVR_ERRFUN)
330 rcvr->errfun (rcvr->data,
331 _("fatal: can't store element %d:%d (%lu:%d): %s"),
332 bucket_dir, i,
333 (unsigned long) dbf->bucket->h_table[i].data_pointer,
334 dbf->bucket->h_table[i].key_size
321 + dbf->bucket->h_table[i].data_size, 335 + dbf->bucket->h_table[i].data_size,
322 gdbm_db_strerror (new_dbf)); 336 gdbm_db_strerror (new_dbf));
323 return -1; 337 return -1;
338 }
324 } 339 }
325 } 340 }
326 } 341 }
327 } 342 }
328 343
329 return 0; 344 return 0;
@@ -353,12 +368,13 @@ gdbm_recover (GDBM_FILE dbf, gdbm_recovery *rcvr, int flags)
353 flags = 0; 368 flags = 0;
354 } 369 }
355 rcvr->recovered_keys = 0; 370 rcvr->recovered_keys = 0;
356 rcvr->recovered_buckets = 0; 371 rcvr->recovered_buckets = 0;
357 rcvr->failed_keys = 0; 372 rcvr->failed_keys = 0;
358 rcvr->failed_buckets = 0; 373 rcvr->failed_buckets = 0;
374 rcvr->duplicate_keys = 0;
359 rcvr->backup_name = NULL; 375 rcvr->backup_name = NULL;
360 376
361 rc = 0; 377 rc = 0;
362 if ((flags & GDBM_RCVR_FORCE) || check_db (dbf)) 378 if ((flags & GDBM_RCVR_FORCE) || check_db (dbf))
363 { 379 {
364 len = strlen (dbf->name); 380 len = strlen (dbf->name);

Return to:

Send suggestions and report system problems to the System administrator.