mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Limit memory usage of PDF parsing https://github.com/siyuan-note/siyuan/pull/9051
This commit is contained in:
parent
06f6534402
commit
f755daee1e
1 changed files with 3 additions and 3 deletions
|
|
@ -846,10 +846,10 @@ func (parser *PdfAssetParser) Parse(absPath string) (ret *AssetParseResult) {
|
||||||
// finally fetch the PDF page text results
|
// finally fetch the PDF page text results
|
||||||
// Note: some workers will process pages faster than other workers depending on the page contents
|
// Note: some workers will process pages faster than other workers depending on the page contents
|
||||||
// the order of returned PDF text pages is random and must be sorted using the pageNo index
|
// the order of returned PDF text pages is random and must be sorted using the pageNo index
|
||||||
pagetext := make([]string, pc.PageCount)
|
pageText := make([]string, pc.PageCount)
|
||||||
for p := 0; p < pc.PageCount; p++ {
|
for p := 0; p < pc.PageCount; p++ {
|
||||||
res := <-results
|
res := <-results
|
||||||
pagetext[res.pageNo] = res.text
|
pageText[res.pageNo] = res.text
|
||||||
if nil != res.err {
|
if nil != res.err {
|
||||||
logging.LogErrorf("convert [%s] of page %d failed: [%s]", tmp, res.pageNo, err)
|
logging.LogErrorf("convert [%s] of page %d failed: [%s]", tmp, res.pageNo, err)
|
||||||
}
|
}
|
||||||
|
|
@ -862,7 +862,7 @@ func (parser *PdfAssetParser) Parse(absPath string) (ret *AssetParseResult) {
|
||||||
|
|
||||||
// loop through ordered PDF text pages and join content for asset parse DB result
|
// loop through ordered PDF text pages and join content for asset parse DB result
|
||||||
content := ""
|
content := ""
|
||||||
for _, pt := range pagetext {
|
for _, pt := range pageText {
|
||||||
content += " " + normalizeNonTxtAssetContent(pt)
|
content += " " + normalizeNonTxtAssetContent(pt)
|
||||||
}
|
}
|
||||||
ret = &AssetParseResult{
|
ret = &AssetParseResult{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue