From 7aaa25840f759412b9c098aed5b6d85bf4548834 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 4 Jun 2023 11:46:35 +0800 Subject: [PATCH 1/3] :art: Support for listing missing files in Settings - Assets https://github.com/siyuan-note/siyuan/issues/8383 --- kernel/model/assets.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/model/assets.go b/kernel/model/assets.go index b7d406287..92cc693c6 100644 --- a/kernel/model/assets.go +++ b/kernel/model/assets.go @@ -694,8 +694,11 @@ func MissingAssets() (ret []string) { } luteEngine := util.NewLute() for _, notebook := range notebooks { - dests := map[string]bool{} + if notebook.Closed { + continue + } + dests := map[string]bool{} pages := pagedPaths(filepath.Join(util.DataDir, notebook.ID), 32) for _, paths := range pages { var trees []*parse.Tree @@ -738,7 +741,6 @@ func MissingAssets() (ret []string) { ret = append(ret, dest) continue } - } } From 11a97adcfe9d6fc4a59ba6eae8d88beb4fb6fb8f Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 4 Jun 2023 11:55:06 +0800 Subject: [PATCH 2/3] :art: Support for listing missing files in Settings - Assets https://github.com/siyuan-note/siyuan/issues/8383 --- app/appearance/langs/en_US.json | 1 - app/appearance/langs/es_ES.json | 1 - app/appearance/langs/fr_FR.json | 1 - app/appearance/langs/zh_CHT.json | 3 +-- app/appearance/langs/zh_CN.json | 3 +-- app/src/config/image.ts | 6 +++--- app/src/config/search.ts | 2 +- 7 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 245ced365..37a82141e 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -635,7 +635,6 @@ "sort": "Sort", "enterFullscreen": "Enter Full Screen", "exitFullscreen": "Exit Full Screen", - "clearUnused": "Unreferenced assets", "clearAll": "Are you sure to clean up all unreferenced assets?", "missingAssets": "Missing assets", "unreferencedAssets": "Unreferenced assets", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index c9ae9e4a4..2ce353eab 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -635,7 +635,6 @@ "sort": "Ordenar", "enterFullscreen": "Entrar en pantalla completa", "exitFullscreen": "Salir de pantalla completa", - "clearUnused": "Activos no utilizados", "clearAll": "¿Está seguro de limpiar todos los activos no referenciados?", "missingAssets": "Activos faltantes", "unreferencedAssets": "Activos sin referencia", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 150b17159..6980d2fa8 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -635,7 +635,6 @@ "sort": "Tri", "enterFullscreen": "plein écran", "exitFullscreen": "Quitter le plein écran", - "clearUnused": "assets non-référencés", "clearAll": "Êtes-vous sûr de nettoyer tous les assets non référencés ?", "missingAssets": "Actifs manquants", "unreferencedAssets": "Actifs non référencés", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 2045dad1e..9c15eb48d 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -635,8 +635,7 @@ "sort": "排序", "enterFullscreen": "進入全螢幕", "exitFullscreen": "退出全螢幕", - "clearUnused": "未引用的資料", - "clearAll": "確認清理所有未引用的資料?", + "clearAll": "確認清理所有未引用的資料文件?", "missingAssets": "丟失的資料文件", "unreferencedAssets": "未引用的資料文件", "paste": "貼上", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 6f1b06705..fbf15a43a 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -635,8 +635,7 @@ "sort": "排序", "enterFullscreen": "进入全屏幕", "exitFullscreen": "退出全屏幕", - "clearUnused": "未引用资源文件", - "clearAll": "确认清理所有未引用资源文件?", + "clearAll": "确认清理所有未引用的资源文件?", "missingAssets": "丢失的资源文件", "unreferencedAssets": "未引用的资源文件", "paste": "粘贴", diff --git a/app/src/config/image.ts b/app/src/config/image.ts index a0fa02719..93ac63cf1 100644 --- a/app/src/config/image.ts +++ b/app/src/config/image.ts @@ -15,7 +15,7 @@ export const image = {
- ${window.siyuan.languages.clearUnused} + ${window.siyuan.languages.unreferencedAssets}
@@ -57,7 +57,7 @@ export const image = { while (target && !target.isEqualNode(image.element)) { const type = target.getAttribute("data-type"); if (target.id === "removeAll") { - confirmDialog(window.siyuan.languages.clearUnused, `${window.siyuan.languages.clearAll}`, () => { + confirmDialog(window.siyuan.languages.deleteOpConfirm, `${window.siyuan.languages.clearAll}`, () => { fetchPost("/api/asset/removeUnusedAssets", {}, response => { getAllModels().asset.forEach(item => { if (response.data.paths.includes(item.path)) { @@ -93,7 +93,7 @@ export const image = { /// #endif } else if (type === "clear") { const pathString = target.parentElement.getAttribute("data-path"); - confirmDialog(window.siyuan.languages.clearUnused, `${window.siyuan.languages.delete} ${pathPosix().basename(pathString)}`, () => { + confirmDialog(window.siyuan.languages.deleteOpConfirm, `${window.siyuan.languages.delete} ${pathPosix().basename(pathString)}`, () => { fetchPost("/api/asset/removeUnusedAsset", { path: pathString, }, response => { diff --git a/app/src/config/search.ts b/app/src/config/search.ts index 919910406..fc26bba30 100644 --- a/app/src/config/search.ts +++ b/app/src/config/search.ts @@ -39,7 +39,7 @@ export const initConfigSearch = (element: HTMLElement, app: App) => { "apiKeyTip", "apiProxy", "apiProxyTip", "apiBaseURL", "apiBaseURLTip"])), // 图片 - getLang(["assets", "clearUnused", "missingAssets"]), + getLang(["assets", "unreferencedAssets", "missingAssets"]), // 导出 getLang(["paragraphBeginningSpace", "md4", "export", "export1", "export2", "export5", "export11", From 9c119f397db70fe0a4f5d33e38d37b342b857fa3 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 4 Jun 2023 12:09:16 +0800 Subject: [PATCH 3/3] :art: Support for listing missing files in Settings - Assets https://github.com/siyuan-note/siyuan/issues/8383 --- .../20200924100744-br924ar.sy | 114 +++++++++++++++++- .../20200915214115-42b8zma.sy | 114 +++++++++++++++++- .../20211226123038-4umgpxy.sy | 114 +++++++++++++++++- 3 files changed, 336 insertions(+), 6 deletions(-) diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100744-br924ar.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100744-br924ar.sy index bb95a49a8..89f3cb6a4 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100744-br924ar.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100744-br924ar.sy @@ -6,7 +6,7 @@ "id": "20200924100744-br924ar", "title": "Assets", "type": "doc", - "updated": "20230505084035" + "updated": "20230604120806" }, "Children": [ { @@ -497,6 +497,10 @@ "updated": "20210130103832" }, "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "tag", @@ -504,7 +508,113 @@ }, { "Type": "NodeText", - "Data": ": Using absolute paths (local or network paths) will not be included Clean up calculations." + "Data": "​: Using absolute paths (local or network paths) will not be included Clean up calculations." + } + ] + }, + { + "ID": "20230604120616-qjigoyt", + "Type": "NodeHeading", + "HeadingLevel": 2, + "Properties": { + "id": "20230604120616-qjigoyt", + "updated": "20230604120623" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "List missing assets" + } + ] + }, + { + "ID": "20230604120616-95dv931", + "Type": "NodeParagraph", + "Properties": { + "id": "20230604120616-95dv931", + "updated": "20230604120637" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "You can view the missing resources in " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "Settings" + }, + { + "Type": "NodeText", + "Data": "​ - " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "Assets" + }, + { + "Type": "NodeText", + "Data": "​, and you can find the references in the global search after copying the path." + } + ] + }, + { + "ID": "20230604120616-tjs4mx0", + "Type": "NodeParagraph", + "Properties": { + "id": "20230604120616-tjs4mx0", + "updated": "20230604120806" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "tag", + "TextMarkTextContent": "Note" + }, + { + "Type": "NodeText", + "Data": "​: To search asset paths, you need to enable " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "Settings" + }, + { + "Type": "NodeText", + "Data": "​ - " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "Search" + }, + { + "Type": "NodeText", + "Data": "​ - " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "Index" + }, + { + "Type": "NodeText", + "Data": "​ - " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "Asset Path" + }, + { + "Type": "NodeText", + "Data": "​." } ] }, diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200915214115-42b8zma.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200915214115-42b8zma.sy index 601fe9491..0179f6e62 100644 --- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200915214115-42b8zma.sy +++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200915214115-42b8zma.sy @@ -6,7 +6,7 @@ "id": "20200915214115-42b8zma", "title": "资源文件", "type": "doc", - "updated": "20230505083923" + "updated": "20230604120815" }, "Children": [ { @@ -499,6 +499,10 @@ "updated": "20210512160659" }, "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "tag", @@ -506,7 +510,113 @@ }, { "Type": "NodeText", - "Data": ":使用绝对路径(本地路径或者是网络路径)不会纳入清理计算。" + "Data": "​:使用绝对路径(本地路径或者是网络路径)不会纳入清理计算。" + } + ] + }, + { + "ID": "20230604115545-plxx5iu", + "Type": "NodeHeading", + "HeadingLevel": 2, + "Properties": { + "id": "20230604115545-plxx5iu", + "updated": "20230604115551" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "查看丢失资源" + } + ] + }, + { + "ID": "20230604115552-qqg9s4j", + "Type": "NodeParagraph", + "Properties": { + "id": "20230604115552-qqg9s4j", + "updated": "20230604115947" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "在" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "设置" + }, + { + "Type": "NodeText", + "Data": "​ - " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "资源" + }, + { + "Type": "NodeText", + "Data": "​ 中可以查看丢失的资源,复制路径后可以在全局搜索中找到引用处。" + } + ] + }, + { + "ID": "20230604115950-hru51yy", + "Type": "NodeParagraph", + "Properties": { + "id": "20230604115950-hru51yy", + "updated": "20230604120815" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "tag", + "TextMarkTextContent": "注意" + }, + { + "Type": "NodeText", + "Data": "​:搜索资源文件路径需要先启用 " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "设置" + }, + { + "Type": "NodeText", + "Data": "​ - " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "搜索" + }, + { + "Type": "NodeText", + "Data": "​ - " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "索引" + }, + { + "Type": "NodeText", + "Data": "​ - " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "资源文件路径" + }, + { + "Type": "NodeText", + "Data": "​。" } ] }, diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123038-4umgpxy.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123038-4umgpxy.sy index af62256a0..bce8f20b3 100644 --- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123038-4umgpxy.sy +++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123038-4umgpxy.sy @@ -5,7 +5,7 @@ "Properties": { "id": "20211226123038-4umgpxy", "title": "資料文件", - "updated": "20230505084013" + "updated": "20230604120825" }, "Children": [ { @@ -482,6 +482,10 @@ "updated": "20211226123051" }, "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "tag", @@ -489,7 +493,113 @@ }, { "Type": "NodeText", - "Data": ":使用絕對路徑(本地路徑或者是網絡路徑)不會納入清理計算。" + "Data": "​:使用絕對路徑(本地路徑或者是網絡路徑)不會納入清理計算。" + } + ] + }, + { + "ID": "20230604120454-cxz64oc", + "Type": "NodeHeading", + "HeadingLevel": 2, + "Properties": { + "id": "20230604120454-cxz64oc", + "updated": "20230604120454" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "查看丟失資源" + } + ] + }, + { + "ID": "20230604120454-k7wee90", + "Type": "NodeParagraph", + "Properties": { + "id": "20230604120454-k7wee90", + "updated": "20230604120520" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "在" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "設置" + }, + { + "Type": "NodeText", + "Data": "​ - " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "資料" + }, + { + "Type": "NodeText", + "Data": "​中可以查看丟失的資源,複製路徑後可以在全局搜索中找到引用處。" + } + ] + }, + { + "ID": "20230604120454-m6jtopr", + "Type": "NodeParagraph", + "Properties": { + "id": "20230604120454-m6jtopr", + "updated": "20230604120825" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "tag", + "TextMarkTextContent": "注意" + }, + { + "Type": "NodeText", + "Data": "​:搜索資源文件路徑需要先啟用 " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "設置" + }, + { + "Type": "NodeText", + "Data": "​ - " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "搜索" + }, + { + "Type": "NodeText", + "Data": "​ - " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "索引" + }, + { + "Type": "NodeText", + "Data": "​ - " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "資源文件路徑" + }, + { + "Type": "NodeText", + "Data": "​。" } ] },