From ac1e9c93533ac3e0978fce75182b7846d815ce10 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Tue, 9 Sep 2008 16:03:37 +0000 Subject: [PATCH] remove cache file even when it is < 20 lines long --- chrome/content/zotero/recognizePDF.js | 32 ++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/chrome/content/zotero/recognizePDF.js b/chrome/content/zotero/recognizePDF.js index 40af53eaf..90de7055b 100644 --- a/chrome/content/zotero/recognizePDF.js +++ b/chrome/content/zotero/recognizePDF.js @@ -292,25 +292,27 @@ Zotero_RecognizePDF.Recognizer.prototype.recognize = function(file, callback, ca var lineLengthsLength = lineLengths.length; if(lineLengthsLength < 20) { this._callback(false, "recognizePDF.noOCR"); - return; + } else { + var sortedLengths = lineLengths.sort(); + var medianLength = sortedLengths[Math.floor(lineLengthsLength/2)]; + + // pick lines within 4 chars of the median (this is completely arbitrary) + this._goodLines = []; + var uBound = medianLength + 4; + var lBound = medianLength - 4; + for (var i=0; i lBound && lineLengths[i] < uBound) this._goodLines.push(lines[i]); + } + + this._startLine = this._iteration = 0; } - var sortedLengths = lineLengths.sort(); - var medianLength = sortedLengths[Math.floor(lineLengthsLength/2)]; - - // pick lines within 4 chars of the median (this is completely arbitrary) - this._goodLines = []; - var uBound = medianLength + 4; - var lBound = medianLength - 4; - for (var i=0; i lBound && lineLengths[i] < uBound) this._goodLines.push(lines[i]); - } - - this._startLine = this._iteration = 0; - inputStream.close(); cacheFile.remove(false); - this._queryGoogle(); + + if(lineLengthsLength >= 20) { + this._queryGoogle(); + } } /**