Changeset 45
- Timestamp:
- 21.11.2006 00:51:34 (2 years ago)
- Files:
-
- trunk/devel/FuzzyOcr/Config.pm (modified) (4 diffs)
- trunk/devel/FuzzyOcr/Hashing.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/devel/FuzzyOcr/Config.pm
r42 r45 19 19 use Mail::SpamAssassin::Logger; 20 20 use Fcntl ':flock'; 21 use DBI; 21 22 use constant HAS_DBI => eval { require DBI; }; 23 use constant HAS_DBD_MYSQL => eval { require DBD::mysql; }; 24 use constant HAS_MLDBM => eval { require MLDBM; }; 25 use constant HAS_DB_FILE => eval { require DB_File; }; 26 use constant HAS_STORABLE => eval { require Storable; }; 22 27 23 28 #Defines the defaults and reads the configuration and wordlists … … 81 86 82 87 sub get_ddb { 88 return undef unless (HAS_DBI and HAS_DBD_MYSQL); 83 89 my $conf = get_config(); 84 90 my %dopts = ( AutoCommit => 1 ); … … 366 372 } 367 373 374 if ($conf->{focr_enable_image_hashing} == 3) { 375 unless (HAS_DBI and HAS_DBD_MYSQL) { 376 $conf->{focr_enable_image_hashing} = 0; 377 debuglog("Disable Image Hashing"); 378 debuglog("Missing DBI") unless HAS_DBI; 379 debuglog("Missing DBD::mysql") unless HAS_DBD_MYSQL; 380 } 381 } 382 if ($conf->{focr_enable_image_hashing} == 2) { 383 unless (HAS_MLDBM and HAS_DB_FILE and HAS_STORABLE) { 384 $conf->{focr_enable_image_hashing} = 0; 385 debuglog("Disable Image Hashing"); 386 debuglog("Missing MLDBM") unless HAS_MLDBM; 387 debuglog("Missing DB_File") unless HAS_DB_FILE; 388 debuglog("Missing Storable") unless HAS_STORABLE; 389 } 390 } 368 391 if ($conf->{focr_enable_image_hashing} == 2 and -r $conf->{focr_digest_db}) { 369 392 my %DB; my $dbm; my $err = 0; … … 429 452 if ($conf->{focr_enable_image_hashing} == 3) { 430 453 my $ddb = $conf->{focr_ddb} = get_ddb(); 431 if (defined $ conf->{focr_ddb}) {454 if (defined $ddb) { 432 455 my $db = $conf->{focr_mysql_db}; 433 456 my $tab = $conf->{focr_mysql_hash}; trunk/devel/FuzzyOcr/Hashing.pm
r44 r45 9 9 use lib "../"; 10 10 use FuzzyOcr::Config qw(get_thresholds get_config set_config debuglog logfile); 11 use DBI;12 use MLDBM qw(DB_File Storable);13 11 use Fcntl; 14 12 use Fcntl ':flock'; … … 60 58 return (0,'') if ( 61 59 ($conf->{focr_enable_image_hashing} == 0) or 62 ( not defined $conf->{focr_ddb})60 ($conf->{focr_enable_image_hashing} == 3 and not defined $conf->{focr_ddb}) 63 61 ); 64 62 my $digest = $_[0]; … … 134 132 } 135 133 elsif ($conf->{focr_enable_image_hashing} == 2) { 134 use MLDBM qw(DB_File Storable); 136 135 my %DB = (); my $dbm; 137 136 tie %DB, 'MLDBM', $dbfile, O_RDWR or $ret++; … … 242 241 } 243 242 elsif ($conf->{focr_enable_image_hashing} == 2) { 243 use MLDBM qw(DB_File Storable); 244 244 my $dbfile = $_[2] || $conf->{focr_db_hash}; 245 245 my %DB = (); … … 341 341 my $ret; 342 342 343 debuglog("fmt_time: When = $when");344 343 if ($when>86400) { 345 344 my $d = int($when/86400);
