some bug fixes
This commit is contained in:
parent
0e49d60994
commit
0e914c629e
16 changed files with 179 additions and 52 deletions
|
|
@ -56,11 +56,11 @@ func New(base string, langs []string, timeout time.Duration) (s *Scanner, err er
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = godrop.Unveil(tcmd, "rx")
|
||||
pcmd, err = exec.LookPath("pdftotext")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
pcmd, err = exec.LookPath("pdftotext")
|
||||
err = godrop.Unveil(tcmd, "rx")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -73,11 +73,11 @@ func New(base string, langs []string, timeout time.Duration) (s *Scanner, err er
|
|||
}
|
||||
for i, l := range langs {
|
||||
lang += l
|
||||
if i < len(langs) {
|
||||
if i < len(langs)-1 {
|
||||
lang += "+"
|
||||
}
|
||||
}
|
||||
args := []string{"-l", lang, "--oem", "2"}
|
||||
args := []string{"-l", lang, "--oem", tesseract_oem}
|
||||
s = &Scanner{
|
||||
base,
|
||||
timeout,
|
||||
|
|
@ -98,14 +98,14 @@ func (s *Scanner) Scan(file string) (filename, text string, err error) {
|
|||
f *os.File
|
||||
)
|
||||
p, _ := filepath.Split(file)
|
||||
filename = filepath.Join(p, core.FileName()+pdfExt)
|
||||
pdfCmd := exec.Command(s.t.cmd, append(s.t.args, []string{scanfile, "stdout", "pdf"}...)...)
|
||||
pdfCmd.Env = s.t.env
|
||||
log.Debugf("%v %s %v", pdfCmd.Env, pdfCmd.Path, pdfCmd.Args)
|
||||
pdf, err = core.Timeout(pdfCmd, s.timeout)
|
||||
pdf, err = timeout(pdfCmd, s.timeout)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
filename = filepath.Join(p, core.FileName()+pdfExt)
|
||||
pdffile = filepath.Join(s.base, filename)
|
||||
f, err = os.OpenFile(pdffile, os.O_RDWR|os.O_CREATE, fs.FileMode)
|
||||
if err != nil {
|
||||
|
|
@ -124,8 +124,9 @@ func (s *Scanner) Scan(file string) (filename, text string, err error) {
|
|||
}
|
||||
txtCmd := exec.Command(s.p.cmd, append(s.p.args, []string{pdffile, "-"}...)...)
|
||||
log.Debugf("%s %v", txtCmd.Path, txtCmd.Args)
|
||||
txt, err := core.Timeout(txtCmd, s.timeout)
|
||||
txt, err := timeout(txtCmd, s.timeout)
|
||||
if err != nil {
|
||||
log.Debugf("killed", err)
|
||||
return
|
||||
}
|
||||
if len(txt) <= 2 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue