mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 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:
parent
e50f23ba02
commit
05d045b1e6
4 changed files with 171 additions and 15 deletions
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": "资源文件内容搜索"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue