Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/naptha/tesseract.js.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalearica <admin@scribeocr.com>2022-08-09 08:29:14 +0300
committerGitHub <noreply@github.com>2022-08-09 08:29:14 +0300
commit66085a7d70af2ac47dac67ac0b1305573ffea318 (patch)
tree26be1a5647b30cf318cea01e707990d6837e7e33
parentadcb5b875986ebe61d7235e64d956d648c53c1dd (diff)
parent01e833576807e3b7ab1337634db805c26498b6bd (diff)
Merge pull request #585 from andreialecu/fix-cachebadresponse
Fix caching of bad langData responses
-rw-r--r--src/worker-script/index.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/worker-script/index.js b/src/worker-script/index.js
index 6507bf1..c0c0fa0 100644
--- a/src/worker-script/index.js
+++ b/src/worker-script/index.js
@@ -99,7 +99,11 @@ const loadLanguage = async ({
}
if (path !== null) {
- const resp = await (isWebWorker ? fetch : adapter.fetch)(`${path}/${lang}.traineddata${gzip ? '.gz' : ''}`);
+ const fetchUrl = `${path}/${lang}.traineddata${gzip ? '.gz' : ''}`;
+ const resp = await (isWebWorker ? fetch : adapter.fetch)(fetchUrl);
+ if (!resp.ok) {
+ throw Error(`Network error while fetching ${fetchUrl}. Response code: ${resp.status}`)
+ }
data = await resp.arrayBuffer();
} else {
data = await adapter.readCache(`${langPath}/${lang}.traineddata${gzip ? '.gz' : ''}`);