mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
tesseract worker restart to aviod memory leak
This commit is contained in:
parent
96b413a365
commit
0259cfe1a7
3 changed files with 85 additions and 25 deletions
src/utils
|
@ -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`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue