diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20230805231614-vqn28eh/20230805231816-h1z9mpc/20230805232134-3d6mx2k.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20230805231614-vqn28eh/20230805231816-h1z9mpc/20230805232134-3d6mx2k.sy index 329d9169b..ef39d8fa7 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20230805231614-vqn28eh/20230805231816-h1z9mpc/20230805232134-3d6mx2k.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20230805231614-vqn28eh/20230805231816-h1z9mpc/20230805232134-3d6mx2k.sy @@ -5,7 +5,7 @@ "Properties": { "id": "20230805232134-3d6mx2k", "title": "Search asset content", - "updated": "20231025095559" + "updated": "20231026085302" }, "Children": [ { @@ -215,7 +215,7 @@ "ListData": {}, "Properties": { "id": "20230903112419-45ps71g", - "updated": "20231025095559" + "updated": "20231026085302" }, "Children": [ { @@ -262,12 +262,58 @@ "Type": "NodeParagraph", "Properties": { "id": "20231025095244-m8ut4h2", - "updated": "20231025095559" + "updated": "20231026085241" }, "Children": [ { "Type": "NodeText", - "Data": "PDFs larger than 128MB or 1024 pages are not supported" + "Data": "PDFs larger than 1024 pages are not supported" + } + ] + } + ] + }, + { + "ID": "20231026085243-o2jstdb", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20231026085243-o2jstdb", + "updated": "20231026085302" + }, + "Children": [ + { + "ID": "20231026085243-3mtefdv", + "Type": "NodeParagraph", + "Properties": { + "id": "20231026085243-3mtefdv", + "updated": "20231026085302" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "By default, PDFs larger than 128MB are not supported. You can set the environment variable " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "code", + "TextMarkTextContent": "SIYUAN_PDF_ASSET_CONTENT_INDEX_MAX_SIZE" + }, + { + "Type": "NodeText", + "Data": "​. The value unit is bytes, for example: " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "code", + "TextMarkTextContent": "SIYUAN_PDF_ASSET_CONTENT_INDEX_MAX_SIZE=256000000" + }, + { + "Type": "NodeText", + "Data": "​ to adjust the upper limit to 256MB" } ] } diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20230805222417-2lj3dvk/20230805225107-qm1m2f5/20230805230218-aea8icj.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20230805222417-2lj3dvk/20230805225107-qm1m2f5/20230805230218-aea8icj.sy index 951fd81bc..2ead13d4a 100644 --- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20230805222417-2lj3dvk/20230805225107-qm1m2f5/20230805230218-aea8icj.sy +++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20230805222417-2lj3dvk/20230805225107-qm1m2f5/20230805230218-aea8icj.sy @@ -5,7 +5,7 @@ "Properties": { "id": "20230805230218-aea8icj", "title": "搜索资源文件内容", - "updated": "20231025095556" + "updated": "20231026085139" }, "Children": [ { @@ -217,7 +217,7 @@ "ListData": {}, "Properties": { "id": "20230903112243-pwm33kc", - "updated": "20231025095556" + "updated": "20231026085139" }, "Children": [ { @@ -264,12 +264,58 @@ "Type": "NodeParagraph", "Properties": { "id": "20231025095053-ee3etgb", - "updated": "20231025095556" + "updated": "20231026085014" }, "Children": [ { "Type": "NodeText", - "Data": "不支持大于 128MB 或 1024 页的 PDF" + "Data": "不支持大于 1024 页的 PDF" + } + ] + } + ] + }, + { + "ID": "20231026085015-163ec6r", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20231026085015-163ec6r", + "updated": "20231026085139" + }, + "Children": [ + { + "ID": "20231026085015-9kucsof", + "Type": "NodeParagraph", + "Properties": { + "id": "20231026085015-9kucsof", + "updated": "20231026085139" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "默认不支持大于 128MB 的 PDF,可通过环境变量 " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "code", + "TextMarkTextContent": "SIYUAN_PDF_ASSET_CONTENT_INDEX_MAX_SIZE" + }, + { + "Type": "NodeText", + "Data": "​ 设置,值的单位是字节,比如:" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "code", + "TextMarkTextContent": "SIYUAN_PDF_ASSET_CONTENT_INDEX_MAX_SIZE=256000000" + }, + { + "Type": "NodeText", + "Data": "​ 将上限调整为 256MB" } ] } @@ -297,7 +343,11 @@ "Children": [ { "Type": "NodeText", - "Data": "Android/iOS 端不支持 PDF 资源文件内容搜索" + "Data": "Android/iOS 端不支持 PDF " + }, + { + "Type": "NodeText", + "Data": "资源文件内容搜索" } ] } diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20230805232636-zh0adz2/20230805232719-04mqbcx/20230805232920-5fdco36.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20230805232636-zh0adz2/20230805232719-04mqbcx/20230805232920-5fdco36.sy index a3c3a6dc5..6ccef72f6 100644 --- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20230805232636-zh0adz2/20230805232719-04mqbcx/20230805232920-5fdco36.sy +++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20230805232636-zh0adz2/20230805232719-04mqbcx/20230805232920-5fdco36.sy @@ -5,7 +5,7 @@ "Properties": { "id": "20230805232920-5fdco36", "title": "搜索資源文件內容", - "updated": "20231025095553" + "updated": "20231026085346" }, "Children": [ { @@ -220,7 +220,7 @@ "ListData": {}, "Properties": { "id": "20230903112449-mq7jbfe", - "updated": "20231025095553" + "updated": "20231026085346" }, "Children": [ { @@ -267,12 +267,58 @@ "Type": "NodeParagraph", "Properties": { "id": "20231025095319-egfy5yi", - "updated": "20231025095553" + "updated": "20231026085317" }, "Children": [ { "Type": "NodeText", - "Data": "不支援大於 128MB 或 1024 頁的 PDF" + "Data": "不支援大於 1024 頁的 PDF" + } + ] + } + ] + }, + { + "ID": "20231026085318-8quzaxe", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20231026085318-8quzaxe", + "updated": "20231026085346" + }, + "Children": [ + { + "ID": "20231026085318-2mkqfy3", + "Type": "NodeParagraph", + "Properties": { + "id": "20231026085318-2mkqfy3", + "updated": "20231026085346" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "預設不支援大於 128MB 的 PDF,可透過環境變數 " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "code", + "TextMarkTextContent": "SIYUAN_PDF_ASSET_CONTENT_INDEX_MAX_SIZE" + }, + { + "Type": "NodeText", + "Data": "​ 設定,值的單位是字節,例如:" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "code", + "TextMarkTextContent": "SIYUAN_PDF_ASSET_CONTENT_INDEX_MAX_SIZE=256000000" + }, + { + "Type": "NodeText", + "Data": "​ 將上限調整為 256MB" } ] } diff --git a/kernel/model/asset_content.go b/kernel/model/asset_content.go index 1da770740..2b5c38fcc 100644 --- a/kernel/model/asset_content.go +++ b/kernel/model/asset_content.go @@ -480,7 +480,10 @@ func NewAssetsSearcher() *AssetsSearcher { const ( TxtAssetContentMaxSize = 1024 * 1024 * 4 PDFAssetContentMaxPage = 1024 - PDFAssetContentMaxSize = 1024 * 1024 * 128 +) + +var ( + PDFAssetContentMaxSize uint64 = 1024 * 1024 * 128 ) type AssetParseResult struct { @@ -829,7 +832,18 @@ func (parser *PdfAssetParser) Parse(absPath string) (ret *AssetParseResult) { return } - if PDFAssetContentMaxSize < len(pdfData) { + if maxSizeVal := os.Getenv("SIYUAN_PDF_ASSET_CONTENT_INDEX_MAX_SIZE"); "" != maxSizeVal { + if maxSize, parseErr := strconv.ParseUint(maxSizeVal, 10, 64); nil == parseErr { + if maxSize != PDFAssetContentMaxSize { + PDFAssetContentMaxSize = maxSize + logging.LogInfof("set PDF asset content index max size to [%s]", humanize.Bytes(maxSize)) + } + } else { + logging.LogWarnf("invalid env [SIYUAN_PDF_ASSET_CONTENT_INDEX_MAX_SIZE]: [%s], parsing failed: ", maxSizeVal, parseErr) + } + } + + if PDFAssetContentMaxSize < uint64(len(pdfData)) { // PDF files larger than 128MB are not included in asset file content searching https://github.com/siyuan-note/siyuan/issues/9500 logging.LogWarnf("ignore large PDF asset [%s] with [%s]", absPath, humanize.Bytes(uint64(len(pdfData)))) return