Package: durep / 0.9-3

40_ignore_corrupt_ds.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Description: Improve handling of the CGI register database.
 Add the option flag O_TRUNC at opening time. The collate
 processing was implemented to begin indexing anew every time,
 so truncating the old file does no harm, but does avoid later
 corruption.
 .
 Should it happen that one of the scan databases was corrupt
 of some unknown reason, any collate task at a later time will
 never get past that scan file in the process of rebuilding the
 overview database. Thus the CGI content will remain outdated.
 .
 A simple test to make sure that $temp{DATA} indeed is defined
 will noticeably decrease the risk of leaving the collated
 database behind.
Author: Mats Erik Andersson <debian@gisladisker.se>
Forwarded: no
Last-Update: 2010-04-14
--- durep-0.9.debian/durep
+++ durep-0.9/durep
@@ -284,7 +284,7 @@ sub collate {
   doAbort("'$opt_collate' is not a valid directory.") unless -d $opt_collate;

   &check_mldbm;
-  tie %db, 'MLDBM', "$opt_collate/durep.cds", O_CREAT|O_RDWR, 0640 or doAbort("Unable to tie file '$opt_collate/durep.cds'");
+  tie %db, 'MLDBM', "$opt_collate/durep.cds", O_CREAT|O_TRUNC|O_RDWR, 0640 or doAbort("Unable to tie file '$opt_collate/durep.cds'");

   my @files;
   my $next_id = 1;
@@ -301,6 +301,11 @@ sub collate {
     my $id = $next_id++;
     my %temp;
     tie %temp, 'MLDBM', "$opt_collate/$file", O_RDONLY, 0640 or doAbort("Unable to tie file '$opt_collate/$file'");
+    if (not defined($temp{DATA})) {
+      --$next_id;	# Revert to first unused marker.
+      untie %temp;
+      next;
+    }
     my %data = (%{$temp{DATA}});
     $data{FILENAME} = $file;
     $data{SIZE} = $temp{1}->{SIZE};