tesseract worker restart to aviod memory leak

This commit is contained in:
mrfry 2022-12-10 16:36:59 +01:00
parent 96b413a365
commit 0259cfe1a7
3 changed files with 85 additions and 25 deletions
src/utils

View file

@ -36,6 +36,7 @@ export default {
statFile: statFile,
renameFile: renameFile,
deleteDir: deleteDir,
formatBytes: formatBytes,
}
import fs from 'fs'
@ -296,3 +297,15 @@ function renameFile(oldPath: string, newPath: string): string {
return null
}
}
function formatBytes(number: number, unit: 'MB' | 'GB' = 'MB'): string {
let res = number / 1024 / 1024 // MB
if (unit === 'MB') {
return `${res} MB`
}
res = res / 1024
if (unit === 'GB') {
return `${res} GB`
}
return `${number} byte`
}