🎨 PDF files larger than 128MB are not included in asset file content searching https://github.com/siyuan-note/siyuan/issues/9500

This commit is contained in:
Daniel 2023-10-26 08:54:37 +08:00
parent e50f23ba02
commit 05d045b1e6
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 171 additions and 15 deletions

View file

@ -5,7 +5,7 @@
"Properties": { "Properties": {
"id": "20230805232134-3d6mx2k", "id": "20230805232134-3d6mx2k",
"title": "Search asset content", "title": "Search asset content",
"updated": "20231025095559" "updated": "20231026085302"
}, },
"Children": [ "Children": [
{ {
@ -215,7 +215,7 @@
"ListData": {}, "ListData": {},
"Properties": { "Properties": {
"id": "20230903112419-45ps71g", "id": "20230903112419-45ps71g",
"updated": "20231025095559" "updated": "20231026085302"
}, },
"Children": [ "Children": [
{ {
@ -262,12 +262,58 @@
"Type": "NodeParagraph", "Type": "NodeParagraph",
"Properties": { "Properties": {
"id": "20231025095244-m8ut4h2", "id": "20231025095244-m8ut4h2",
"updated": "20231025095559" "updated": "20231026085241"
}, },
"Children": [ "Children": [
{ {
"Type": "NodeText", "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"
} }
] ]
} }

View file

@ -5,7 +5,7 @@
"Properties": { "Properties": {
"id": "20230805230218-aea8icj", "id": "20230805230218-aea8icj",
"title": "搜索资源文件内容", "title": "搜索资源文件内容",
"updated": "20231025095556" "updated": "20231026085139"
}, },
"Children": [ "Children": [
{ {
@ -217,7 +217,7 @@
"ListData": {}, "ListData": {},
"Properties": { "Properties": {
"id": "20230903112243-pwm33kc", "id": "20230903112243-pwm33kc",
"updated": "20231025095556" "updated": "20231026085139"
}, },
"Children": [ "Children": [
{ {
@ -264,12 +264,58 @@
"Type": "NodeParagraph", "Type": "NodeParagraph",
"Properties": { "Properties": {
"id": "20231025095053-ee3etgb", "id": "20231025095053-ee3etgb",
"updated": "20231025095556" "updated": "20231026085014"
}, },
"Children": [ "Children": [
{ {
"Type": "NodeText", "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": [ "Children": [
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": "Android/iOS 端不支持 PDF 资源文件内容搜索" "Data": "Android/iOS 端不支持 PDF "
},
{
"Type": "NodeText",
"Data": "资源文件内容搜索"
} }
] ]
} }

View file

@ -5,7 +5,7 @@
"Properties": { "Properties": {
"id": "20230805232920-5fdco36", "id": "20230805232920-5fdco36",
"title": "搜索資源文件內容", "title": "搜索資源文件內容",
"updated": "20231025095553" "updated": "20231026085346"
}, },
"Children": [ "Children": [
{ {
@ -220,7 +220,7 @@
"ListData": {}, "ListData": {},
"Properties": { "Properties": {
"id": "20230903112449-mq7jbfe", "id": "20230903112449-mq7jbfe",
"updated": "20231025095553" "updated": "20231026085346"
}, },
"Children": [ "Children": [
{ {
@ -267,12 +267,58 @@
"Type": "NodeParagraph", "Type": "NodeParagraph",
"Properties": { "Properties": {
"id": "20231025095319-egfy5yi", "id": "20231025095319-egfy5yi",
"updated": "20231025095553" "updated": "20231026085317"
}, },
"Children": [ "Children": [
{ {
"Type": "NodeText", "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"
} }
] ]
} }

View file

@ -480,7 +480,10 @@ func NewAssetsSearcher() *AssetsSearcher {
const ( const (
TxtAssetContentMaxSize = 1024 * 1024 * 4 TxtAssetContentMaxSize = 1024 * 1024 * 4
PDFAssetContentMaxPage = 1024 PDFAssetContentMaxPage = 1024
PDFAssetContentMaxSize = 1024 * 1024 * 128 )
var (
PDFAssetContentMaxSize uint64 = 1024 * 1024 * 128
) )
type AssetParseResult struct { type AssetParseResult struct {
@ -829,7 +832,18 @@ func (parser *PdfAssetParser) Parse(absPath string) (ret *AssetParseResult) {
return 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 // 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)))) logging.LogWarnf("ignore large PDF asset [%s] with [%s]", absPath, humanize.Bytes(uint64(len(pdfData))))
return return