Changeset 117
- Timestamp:
- 17.12.2006 00:48:10 (2 years ago)
- Files:
-
- trunk/devel/FuzzyOcr.pm (modified) (1 diff)
- trunk/devel/FuzzyOcr/Config.pm (modified) (10 diffs)
- trunk/devel/samples/ocr-multi.eml (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/devel/FuzzyOcr.pm
r113 r117 310 310 311 311 # Try to load personal wordlist 312 if ($conf->{focr_personal_wordlist} =~ m/^\//) { 313 read_words( $conf->{focr_personal_wordlist} ); 314 } else { 315 my $peruserlist = $main->sed_path($conf->{focr_personal_wordlist}); 316 if ( -r $peruserlist ) { 317 read_words( $peruserlist ); 312 unless ($conf->{focr_no_homedirs}) { 313 if ($conf->{focr_personal_wordlist} =~ m/^\//) { 314 read_words( $conf->{focr_personal_wordlist} ); 318 315 } else { 319 # Only complain if the file exists 320 if ( -e $peruserlist ) { 321 errorlog("Cannot read personal_wordlist: $peruserlist, skipping..."); 322 } 323 } 324 } 325 316 my $peruserlist = $main->sed_path($conf->{focr_personal_wordlist}); 317 if ( -r $peruserlist ) { 318 read_words( $peruserlist ); 319 } else { 320 # Only complain if the file exists 321 if ( -e $peruserlist ) { 322 errorlog("Cannot read personal_wordlist: $peruserlist, skipping..."); 323 } 324 } 325 } 326 } 326 327 my $haserr; 327 328 foreach my $filename (keys %imgfiles) { trunk/devel/FuzzyOcr/Config.pm
r116 r117 55 55 our $dbref; 56 56 57 # State of the plugin, already initialized? 58 our $initialized = 0; 59 57 60 our @bin_utils = qw/gifsicle 58 61 giffix … … 304 307 type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING 305 308 }); 306 309 push (@cmds, { 310 setting => 'focr_no_homedirs', 311 default => 0, 312 type => $Mail::SpamAssassin::Conf::CONF_TYPE_BOOL 313 }); 307 314 push (@cmds, { 308 315 setting => 'focr_db_hash', … … 508 515 sub parse_config { 509 516 my ($self, $opts) = @_; 517 518 # Don't parse a config twice 519 if ($initialized) { return 1; } 520 510 521 if ($opts->{key} eq 'focr_end_config') { 511 522 $conf = $opts->{conf}; … … 514 525 515 526 # Parse preprocessor file 516 my $pfile = $ main->sed_path($conf->{'focr_preprocessor_file'});527 my $pfile = $conf->{'focr_preprocessor_file'}; 517 528 infolog("Starting preprocessor parser for file \"$pfile\"..."); 518 529 ($retcode, @preprocessors) = parse_preprocessors($pfile); … … 523 534 524 535 # Parse scanset file 525 my $sfile = $ main->sed_path($conf->{'focr_scanset_file'});536 my $sfile = $conf->{'focr_scanset_file'}; 526 537 infolog("Starting scanset parser for file \"$sfile\"..."); 527 538 ($retcode, @scansets) = parse_scansets($sfile); … … 530 541 return 0; 531 542 } 543 532 544 return 1; 533 545 } elsif ($opts->{key} eq 'focr_bin_helper') { … … 557 569 sub finish_parsing_end { 558 570 my ($self, $opts) = @_; 571 572 # Don't call this function twice 573 if ($initialized) { return 1; } 574 559 575 my $main = $self->{main}; 560 576 $conf = $opts->{conf}; … … 638 654 errorlog("Missing DBI") unless HAS_DBI; 639 655 errorlog("Missing DBD::mysql") unless HAS_DBD_MYSQL; 656 } 657 658 # Warn if MLDBM databases are present, but can't be imported 659 unless (HAS_MLDBM and HAS_DB_FILE and HAS_STORABLE and (-r $conf->{focr_db_hash} or -r $conf->{focr_db_safe})) { 660 infolog("Importing for MLDBM databases not available (dependencies missing)"); 640 661 } 641 662 } … … 717 738 } 718 739 } 719 if ($conf->{focr_enable_image_hashing} == 3 and defined (my $ddb = get_mysql_ddb())) { 740 if ($conf->{focr_enable_image_hashing} == 3 and defined (my $ddb = get_mysql_ddb()) 741 and (-r $conf->{focr_db_hash} or -r $conf->{focr_db_safe}) 742 and HAS_MLDBM and HAS_DB_FILE and HAS_STORABLE) { 743 720 744 import MLDBM qw(DB_File Storable); 721 745 my $db = $conf->{focr_mysql_db}; … … 802 826 read_words( $conf->{focr_global_wordlist} , 'Global'); 803 827 1; 828 829 # Important: We parsed the config now and did all post config parsing stuff 830 # don't do it again (for amavisd and other 3rd party applications using the SA API directly) 831 $initialized = 1; 804 832 } 805 833
