Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: Improve snapshot file detection and full checks https://github.com/siyuan-note/siyuan/issues/20861

Daniel469a377c9146
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index c58ecda23d..d5dc725b13 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "فحص المحتوى بالكامل",
+ "fullCheckSnapshotTip": "قراءة جميع الملفات المحلية لاكتشاف تغييرات المحتوى حتى مع ثبات الحجم ووقت التعديل، وإنشاء لقطة عند الحاجة؛ لن تُنزّل الموارد لهذا الفحص، وقد تستغرق مساحات العمل الكبيرة وقتًا أطول",
"listMindmapDocumentViewport": "نافذة عرض المستند",
"listMindmapNodeColor": "لون العقدة",
"listMindmapPaletteWaves": "أمواج",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index 0a5f902b7e..bd71fb7c25 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Vollständige Inhaltsprüfung",
+ "fullCheckSnapshotTip": "Alle lokalen Dateien lesen, um Inhaltsänderungen auch bei unveränderter Größe und Änderungszeit zu erkennen und bei Bedarf einen Schnappschuss zu erstellen; Ressourcen werden dafür nicht heruntergeladen, große Arbeitsbereiche können mehr Zeit benötigen",
"listMindmapDocumentViewport": "Dokumentausschnitt",
"listMindmapNodeColor": "Knotenfarbe",
"listMindmapPaletteWaves": "Wellen",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index b040f919c7..f39956e656 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Full content check",
+ "fullCheckSnapshotTip": "Read all local files to detect content changes even when size and modification time are unchanged, and create a snapshot if needed; resources are not downloaded for this check, and large workspaces may take longer",
"listMindmapDocumentViewport": "Document viewport",
"listMindmapNodeColor": "Node color",
"listMindmapPaletteWaves": "Waves",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index dba8430eb2..8f1771a4c7 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Comprobación completa del contenido",
+ "fullCheckSnapshotTip": "Leer todos los archivos locales para detectar cambios de contenido aunque no cambien el tamaño ni la fecha de modificación, y crear una instantánea si es necesario; no se descargan recursos para esta comprobación y los espacios de trabajo grandes pueden tardar más",
"listMindmapDocumentViewport": "Área visible del documento",
"listMindmapNodeColor": "Color del nodo",
"listMindmapPaletteWaves": "Olas",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index a51d2917cc..2f50c2e7d4 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Vérification complète du contenu",
+ "fullCheckSnapshotTip": "Lire tous les fichiers locaux pour détecter les changements de contenu même si leur taille et leur date de modification restent identiques, puis créer un instantané si nécessaire ; aucune ressource n’est téléchargée pour cette vérification et les grands espaces de travail peuvent demander plus de temps",
"listMindmapDocumentViewport": "Zone visible du document",
"listMindmapNodeColor": "Couleur du nœud",
"listMindmapPaletteWaves": "Vagues",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index 16dbb320ff..c17d3bb61b 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "בדיקת תוכן מלאה",
+ "fullCheckSnapshotTip": "קריאת כל הקבצים המקומיים לזיהוי שינויי תוכן גם כשהגודל וזמן השינוי נשארו זהים, ויצירת תמונת מצב לפי הצורך; משאבים לא יורדו לצורך הבדיקה, וסביבות עבודה גדולות עשויות לדרוש זמן רב יותר",
"listMindmapDocumentViewport": "אזור התצוגה של המסמך",
"listMindmapNodeColor": "צבע הצומת",
"listMindmapPaletteWaves": "גלים",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index c8b6fa02e3..34c0593f21 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "सामग्री की पूरी जाँच",
+ "fullCheckSnapshotTip": "आकार और संशोधन समय समान रहने पर भी सामग्री में बदलाव खोजने के लिए सभी स्थानीय फ़ाइलें पढ़ें और ज़रूरत होने पर स्नैपशॉट बनाएँ; इस जाँच के लिए संसाधन डाउनलोड नहीं होंगे और बड़े कार्यक्षेत्रों में अधिक समय लग सकता है",
"listMindmapDocumentViewport": "दस्तावेज़ का दृश्य क्षेत्र",
"listMindmapNodeColor": "नोड का रंग",
"listMindmapPaletteWaves": "लहरें",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index 40a5c166de..2c8ea5a98c 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Pemeriksaan isi menyeluruh",
+ "fullCheckSnapshotTip": "Baca semua berkas lokal untuk mendeteksi perubahan isi meskipun ukuran dan waktu modifikasi tetap sama, lalu buat snapshot jika diperlukan; sumber daya tidak diunduh untuk pemeriksaan ini dan ruang kerja besar dapat memerlukan waktu lebih lama",
"listMindmapDocumentViewport": "Area pandang dokumen",
"listMindmapNodeColor": "Warna simpul",
"listMindmapPaletteWaves": "Ombak",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index 31f8fe8686..49203dc77a 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Verifica completa del contenuto",
+ "fullCheckSnapshotTip": "Legge tutti i file locali per rilevare modifiche al contenuto anche se dimensioni e data di modifica restano invariate, creando un’istantanea se necessario; non vengono scaricate risorse per questa verifica e gli spazi di lavoro grandi possono richiedere più tempo",
"listMindmapDocumentViewport": "Area visibile del documento",
"listMindmapNodeColor": "Colore del nodo",
"listMindmapPaletteWaves": "Onde",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index 15b06b9d5e..dcccef12c8 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "内容の完全チェック",
+ "fullCheckSnapshotTip": "ローカルの全ファイルを読み取り、サイズと更新日時が変わらない内容の変更も検出し、必要ならスナップショットを作成します。チェックのためのリソースのダウンロードは行わず、大きなワークスペースでは時間がかかる場合があります",
"listMindmapDocumentViewport": "ドキュメントの表示範囲",
"listMindmapNodeColor": "ノードの色",
"listMindmapPaletteWaves": "波",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index ffe5445a46..86cb042780 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "전체 내용 검사",
+ "fullCheckSnapshotTip": "모든 로컬 파일을 읽어 크기와 수정 시간이 같아도 내용 변경을 감지하고 필요하면 스냅샷을 만듭니다. 검사를 위해 리소스를 다운로드하지 않으며 큰 작업 공간에서는 시간이 더 걸릴 수 있습니다",
"listMindmapDocumentViewport": "문서 보기 영역",
"listMindmapNodeColor": "노드 색상",
"listMindmapPaletteWaves": "물결",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index 30bb841e3f..adf9fa1a23 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Volledige inhoudscontrole",
+ "fullCheckSnapshotTip": "Lees alle lokale bestanden om inhoudswijzigingen te vinden, ook als grootte en wijzigingstijd gelijk blijven, en maak zo nodig een momentopname; bronnen worden hiervoor niet gedownload en grote werkruimten kunnen meer tijd kosten",
"listMindmapDocumentViewport": "Documentvenster",
"listMindmapNodeColor": "Knooppuntkleur",
"listMindmapPaletteWaves": "Golven",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index a9a69da96d..1569e8936c 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Pełna kontrola zawartości",
+ "fullCheckSnapshotTip": "Odczytaj wszystkie pliki lokalne, aby wykryć zmiany zawartości mimo niezmienionego rozmiaru i czasu modyfikacji, i w razie potrzeby utwórz migawkę; zasoby nie są pobierane na potrzeby tej kontroli, a duże obszary robocze mogą wymagać więcej czasu",
"listMindmapDocumentViewport": "Obszar widoku dokumentu",
"listMindmapNodeColor": "Kolor węzła",
"listMindmapPaletteWaves": "Fale",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index ac8230d2ee..bb9765c70e 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Verificação completa do conteúdo",
+ "fullCheckSnapshotTip": "Ler todos os arquivos locais para detectar alterações no conteúdo mesmo com tamanho e data de modificação inalterados, e criar um instantâneo se necessário; recursos não são baixados para esta verificação e espaços de trabalho grandes podem demorar mais",
"listMindmapDocumentViewport": "Área visível do documento",
"listMindmapNodeColor": "Cor do nó",
"listMindmapPaletteWaves": "Ondas",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index 4f1f2ae4aa..eb186e7b98 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Полная проверка содержимого",
+ "fullCheckSnapshotTip": "Прочитать все локальные файлы, чтобы найти изменения содержимого даже при неизменных размере и времени изменения, и при необходимости создать снимок; ресурсы для проверки не загружаются, а большие рабочие пространства могут потребовать больше времени",
"listMindmapDocumentViewport": "Область просмотра документа",
"listMindmapNodeColor": "Цвет узла",
"listMindmapPaletteWaves": "Волны",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index c24d6e361e..91a7c283ce 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Úplná kontrola obsahu",
+ "fullCheckSnapshotTip": "Prečítať všetky lokálne súbory na zistenie zmien obsahu aj pri nezmenenej veľkosti a čase úpravy a podľa potreby vytvoriť snímku; zdroje sa na túto kontrolu nesťahujú a veľké pracovné priestory môžu vyžadovať viac času",
"listMindmapDocumentViewport": "Oblasť zobrazenia dokumentu",
"listMindmapNodeColor": "Farba uzla",
"listMindmapPaletteWaves": "Vlny",
diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.json
index 43baa0fae8..f29db7b25c 100644
--- a/app/appearance/langs/sr.json
+++ b/app/appearance/langs/sr.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Потпуна провера садржаја",
+ "fullCheckSnapshotTip": "Прочитајте све локалне датотеке да бисте открили промене садржаја и када су величина и време измене исти и по потреби направите снимак; ресурси се не преузимају ради ове провере, а велики радни простори могу захтевати више времена",
"listMindmapDocumentViewport": "Област приказа документа",
"listMindmapNodeColor": "Боја чвора",
"listMindmapPaletteWaves": "Talasi",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index ac3a80d513..6ffc1b552a 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "ตรวจสอบเนื้อหาทั้งหมด",
+ "fullCheckSnapshotTip": "อ่านไฟล์ภายในเครื่องทั้งหมดเพื่อตรวจหาการเปลี่ยนแปลงของเนื้อหา แม้ขนาดและเวลาแก้ไขจะเท่าเดิม และสร้างสแนปช็อตเมื่อจำเป็น โดยจะไม่ดาวน์โหลดทรัพยากรเพื่อการตรวจสอบนี้ และพื้นที่ทำงานขนาดใหญ่อาจใช้เวลานานขึ้น",
"listMindmapDocumentViewport": "ขอบเขตมุมมองเอกสาร",
"listMindmapNodeColor": "สีโหนด",
"listMindmapPaletteWaves": "คลื่น",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index f127a75de7..ba1590e961 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Tam içerik denetimi",
+ "fullCheckSnapshotTip": "Boyut ve değiştirilme zamanı aynı kalsa bile içerik değişikliklerini bulmak için tüm yerel dosyaları okuyun ve gerekirse anlık görüntü oluşturun; bu denetim için kaynaklar indirilmez ve büyük çalışma alanlarında daha uzun sürebilir",
"listMindmapDocumentViewport": "Belge görünüm alanı",
"listMindmapNodeColor": "Düğüm rengi",
"listMindmapPaletteWaves": "Dalgalar",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index 04a45ffdd0..ffbd6ba117 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "Повна перевірка вмісту",
+ "fullCheckSnapshotTip": "Прочитати всі локальні файли, щоб виявити зміни вмісту навіть за незмінних розміру та часу зміни, і за потреби створити знімок; ресурси для перевірки не завантажуються, а великі робочі простори можуть потребувати більше часу",
"listMindmapDocumentViewport": "Область перегляду документа",
"listMindmapNodeColor": "Колір вузла",
"listMindmapPaletteWaves": "Хвилі",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index 7bb9d067b5..5da37d0b0b 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "完整校验",
+ "fullCheckSnapshotTip": "读取所有本地文件,检查大小和修改时间未变的内容变化,必要时创建快照;不会为校验主动下载资源,大型工作空间可能耗时较长",
"listMindmapDocumentViewport": "文档视口",
"listMindmapNodeColor": "节点颜色",
"listMindmapPaletteWaves": "浪潮",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index 8998cf1707..65519d41dd 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -1,4 +1,6 @@
{
+ "fullCheckSnapshot": "完整校驗",
+ "fullCheckSnapshotTip": "讀取所有本機檔案,檢查大小與修改時間未變的內容變更,必要時建立快照;不會為校驗主動下載資源,大型工作空間可能耗時較長",
"listMindmapDocumentViewport": "文件視口",
"listMindmapNodeColor": "節點顏色",
"listMindmapPaletteWaves": "浪潮",
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20210615213222-vs5tzbd.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20210615213222-vs5tzbd.sy
index 14e1d0b766..5142030ae3 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20210615213222-vs5tzbd.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20210615213222-vs5tzbd.sy
@@ -6,7 +6,7 @@
"id": "20210615213222-vs5tzbd",
"title": "Data history",
"type": "doc",
- "updated": "20261024164212"
+ "updated": "20261024203645"
},
"Children": [
{
@@ -1160,7 +1160,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20220615120602-drz9hwc",
- "updated": "20261024164212"
+ "updated": "20261024203645"
},
"Children": [
{
@@ -1374,7 +1374,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20220615120602-wp2lnbq",
- "updated": "20261016111431"
+ "updated": "20261024203645"
},
"Children": [
{
@@ -1550,6 +1550,47 @@
}
]
},
+ {
+ "ID": "20261024203645-1uu50u4",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261024203645-1uu50u4",
+ "updated": "20261024203645"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "If an external program changes content while preserving both file size and modification time, use "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Data History"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Data snapshot"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Full content check"
+ },
+ {
+ "Type": "NodeText",
+ "Data": ", enter a memo, and confirm. The check reads all local files included in snapshots and creates a snapshot when changes are found. Resources that have not been downloaded retain their existing versions and are not downloaded for the check. Large workspaces may take longer."
+ }
+ ]
+ },
{
"ID": "20220615120602-nzrp6gt",
"Type": "NodeHeading",
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20210615211733-v6rzowm.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20210615211733-v6rzowm.sy
index 0110970602..4eded95332 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20210615211733-v6rzowm.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20210615211733-v6rzowm.sy
@@ -6,7 +6,7 @@
"id": "20210615211733-v6rzowm",
"title": "数据历史",
"type": "doc",
- "updated": "20261016112108"
+ "updated": "20261024203645"
},
"Children": [
{
@@ -1144,7 +1144,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20220615112531-5yos96d",
- "updated": "20261016111710"
+ "updated": "20261024203645"
},
"Children": [
{
@@ -1357,7 +1357,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20220615112535-k8n73hd",
- "updated": "20261016111431"
+ "updated": "20261024203645"
},
"Children": [
{
@@ -1532,6 +1532,47 @@
}
]
},
+ {
+ "ID": "20261024203645-jje7alu",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261024203645-jje7alu",
+ "updated": "20261024203645"
+ },
+ "Children": [
+ {
+ "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": " 中填写备注并确认。该操作读取快照范围内所有本地已落盘文件,发现变化时创建快照;未下载的资源保留原版本,不会为校验主动下载。大型工作空间可能耗时较长。"
+ }
+ ]
+ },
{
"ID": "20220615114301-099icf4",
"Type": "NodeHeading",
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122707-8cr09co.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122707-8cr09co.sy
index 6d811afeea..6128498eb6 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122707-8cr09co.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122707-8cr09co.sy
@@ -6,7 +6,7 @@
"id": "20211226122707-8cr09co",
"title": "資料歷史",
"type": "doc",
- "updated": "20261024163429"
+ "updated": "20261024203645"
},
"Children": [
{
@@ -1136,7 +1136,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20220615120134-cdqs2gt",
- "updated": "20261016111710"
+ "updated": "20261024203645"
},
"Children": [
{
@@ -1350,7 +1350,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20220615120134-165fbc0",
- "updated": "20261016111431"
+ "updated": "20261024203645"
},
"Children": [
{
@@ -1526,6 +1526,47 @@
}
]
},
+ {
+ "ID": "20261024203645-v4jqas9",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261024203645-v4jqas9",
+ "updated": "20261024203645"
+ },
+ "Children": [
+ {
+ "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": " 中填寫備註並確認。此操作讀取快照範圍內所有已儲存於本機的檔案,發現變更時建立快照;未下載的資源保留原版本,不會為校驗主動下載。大型工作空間可能耗時較長。"
+ }
+ ]
+ },
{
"ID": "20220615120134-kbof9pl",
"Type": "NodeHeading",
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-txrc7z1.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-txrc7z1.sy
index e5593fa34a..d05db4ecc8 100644
--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-txrc7z1.sy
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-txrc7z1.sy
@@ -7,7 +7,7 @@
"id": "20240530101000-txrc7z1",
"title": "データ履歴",
"type": "doc",
- "updated": "20261024164212"
+ "updated": "20261024203645"
},
"Children": [
{
@@ -1231,7 +1231,7 @@
"Properties": {
"ID": "20240530101000-b78egg3",
"id": "20240530101000-sy5cmkg",
- "updated": "20261024164212"
+ "updated": "20261024203645"
},
"Children": [
{
@@ -1473,7 +1473,7 @@
"Properties": {
"ID": "20240530101000-bah2zqg",
"id": "20240530101000-16a1pk9",
- "updated": "20261016111431"
+ "updated": "20261024203645"
},
"Children": [
{
@@ -1664,6 +1664,47 @@
}
]
},
+ {
+ "ID": "20261024203645-xznpz7s",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261024203645-xznpz7s",
+ "updated": "20261024203645"
+ },
+ "Children": [
+ {
+ "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": " でメモを入力して確定してください。スナップショットの対象となるローカル保存済みの全ファイルを読み取り、変更が見つかればスナップショットを作成します。未ダウンロードのリソースは既存のバージョンを保持し、チェックのためにダウンロードすることはありません。大きなワークスペースでは時間がかかる場合があります。"
+ }
+ ]
+ },
{
"ID": "20240530101000-bhs49zm",
"Type": "NodeHeading",
diff --git a/app/src/history/history.ts b/app/src/history/history.ts
index 557ca4e7bf..3f2b7fb06a 100644
--- a/app/src/history/history.ts
+++ b/app/src/history/history.ts
@@ -41,14 +41,14 @@ const destroyRepoPanel = (root: Element) => {
});
};
-const openSnapshotMemo = (repoElement: Element, id?: string, memo = "") => {
+const openSnapshotMemo = (repoElement: Element, id?: string, memo = "", fullCheck = false) => {
const dialog = openInputDialog({
title: id ? window.siyuan.languages.editSnapshotMemo : window.siyuan.languages.snapshotMemo,
value: memo,
multiline: true,
resize: "vertical",
placeholder: window.siyuan.languages.snapshotMemoTip,
- description: id ? window.siyuan.languages.snapshotMemoLocalTip : undefined,
+ description: id ? window.siyuan.languages.snapshotMemoLocalTip : fullCheck ? window.siyuan.languages.fullCheckSnapshotTip : undefined,
onConfirm: async (value, dialog) => {
const textarea = dialog.element.querySelector("textarea");
const button = dialog.element.querySelector<HTMLButtonElement>(".b3-button--text");
@@ -64,9 +64,11 @@ const openSnapshotMemo = (repoElement: Element, id?: string, memo = "") => {
renderRepo(repoElement, parseInt(repoElement.getAttribute("data-page")) || 1);
});
} else {
- await fetchPost("/api/repo/createSnapshot", {memo: value}, (response) => {
- if (response.data.created) {
+ await fetchPost("/api/repo/createSnapshot", {memo: value, fullCheck}, (response) => {
+ if (response.data.created || fullCheck) {
dialog.destroy();
+ }
+ if (response.data.created) {
renderRepo(repoElement, 1);
}
});
@@ -524,6 +526,7 @@ export const openHistory = (app: App, tab: "doc" | "notebook" | "repo" = "doc",
<button class="b3-button b3-button--outline" data-type="genRepo">
<svg><use xlink:href="#iconAdd"></use></svg>${window.siyuan.languages.createSnapshot}
</button>
+ <button class="b3-button b3-button--outline" data-type="fullCheckRepo">${window.siyuan.languages.fullCheckSnapshot}</button>
</div>
</div>
<div class="fn__flex fn__flex-1 history__panel">
@@ -959,6 +962,13 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
event.stopPropagation();
event.preventDefault();
break;
+ } else if (type === "fullCheckRepo") {
+ if (!window.siyuan.config.readonly && !target.hasAttribute("disabled")) {
+ openSnapshotMemo(repoElement, undefined, "", true);
+ }
+ event.stopPropagation();
+ event.preventDefault();
+ break;
} else if (type === "genRepo") {
if (!window.siyuan.config.readonly && !target.hasAttribute("disabled")) {
target.setAttribute("disabled", "disabled");
diff --git a/app/src/history/historyRegression.test.ts b/app/src/history/historyRegression.test.ts
index 5ef5589246..9697eb2363 100644
--- a/app/src/history/historyRegression.test.ts
+++ b/app/src/history/historyRegression.test.ts
@@ -55,3 +55,61 @@ test("notebook recovery renders a native button in a visible history row", () =>
assert.match(element.innerHTML, /<button type="button"[^>]*data-type="rollback"[^>]*aria-label="Rollback">/);
assert.doesNotMatch(element.innerHTML, /b3-list-item--hide-action/);
});
+
+test("snapshot creation sends full checks, closes completed checks and retains unchanged normal drafts", async () => {
+ for (const fullCheck of [false, true]) {
+ for (const created of [false, true]) {
+ let options: {description?: string, onConfirm: (value: string, dialog: unknown) => Promise<void>};
+ const button = {disabled: false};
+ const textarea = {readOnly: false};
+ let closed = 0;
+ const refreshed: number[] = [];
+ const requests: {path: string, body: unknown}[] = [];
+ const dialog = {
+ element: {setAttribute() {}, querySelector: (selector: string) => selector === "textarea" ? textarea : button},
+ destroy: () => closed++,
+ };
+ const dependencies = {
+ window: {siyuan: {languages: {snapshotMemo: "Memo", fullCheckSnapshotTip: "Read all local files"}}},
+ Constants: {DIALOG_SNAPSHOTMEMO: "snapshot-memo"},
+ openInputDialog: (value: typeof options) => { options = value; return dialog; },
+ renderRepo: (_element: unknown, page: number) => refreshed.push(page),
+ fetchPost: async (path: string, body: unknown, callback: (response: unknown) => void) => {
+ requests.push({path, body});
+ assert.equal(button.disabled, true);
+ assert.equal(textarea.readOnly, true);
+ callback({data: {created}});
+ },
+ };
+ const open = new Function(...Object.keys(dependencies), extract("openSnapshotMemo") + "\nreturn openSnapshotMemo;")(...Object.values(dependencies));
+ open({}, undefined, "", fullCheck);
+ assert.equal(options.description, fullCheck ? "Read all local files" : undefined);
+ await options.onConfirm("memo", dialog);
+ assert.deepEqual(requests, [{path: "/api/repo/createSnapshot", body: {memo: "memo", fullCheck}}]);
+ assert.equal(closed, created || fullCheck ? 1 : 0);
+ assert.deepEqual(refreshed, created ? [1] : []);
+ assert.equal(button.disabled, false);
+ assert.equal(textarea.readOnly, false);
+ }
+ }
+});
+
+test("a failed full snapshot check retains the memo and releases the busy controls", async () => {
+ let options: {onConfirm: (value: string, dialog: unknown) => Promise<void>};
+ const button = {disabled: false};
+ const textarea = {readOnly: false};
+ const dialog = {
+ element: {setAttribute() {}, querySelector: (selector: string) => selector === "textarea" ? textarea : button},
+ destroy: () => assert.fail("failed check closed the dialog"),
+ };
+ const dependencies = {
+ window: {siyuan: {languages: {}}}, Constants: {},
+ openInputDialog: (value: typeof options) => { options = value; return dialog; },
+ fetchPost: async () => { throw new Error("read failed"); },
+ };
+ const open = new Function(...Object.keys(dependencies), extract("openSnapshotMemo") + "\nreturn openSnapshotMemo;")(...Object.values(dependencies));
+ open({}, undefined, "memo", true);
+ await assert.rejects(options.onConfirm("memo", dialog), /read failed/);
+ assert.equal(button.disabled, false);
+ assert.equal(textarea.readOnly, false);
+});
diff --git a/app/src/history/repoPanel.ts b/app/src/history/repoPanel.ts
index 8394584b1a..75c4039e21 100644
--- a/app/src/history/repoPanel.ts
+++ b/app/src/history/repoPanel.ts
@@ -132,12 +132,13 @@ export const initRepoPanel = (root: HTMLElement, render: (pane: Element, page: n
<button class="block__icon block__icon--show history__snapshot-mobile-control" data-action="source-more" aria-label="${lang.more}"><svg><use xlink:href="#iconMore"></use></svg></button>
</div>
<label class="history__snapshot-toolbar fn__none"><input type="checkbox" class="history__snapshot-check" data-repo-all> ${lang.selectAll}</label>${template}`;
- const createButton = pane.querySelector('[data-type="genRepo"]');
- if (source === "local") {
- pane.querySelector('[data-action="purge"]').before(createButton);
- } else {
- createButton.remove();
- }
+ pane.querySelectorAll('[data-type="genRepo"], [data-type="fullCheckRepo"]').forEach(button => {
+ if (source === "local") {
+ pane.querySelector('[data-action="purge"]').before(button);
+ } else {
+ button.remove();
+ }
+ });
const pagination = document.createElement("div");
pagination.className = "history__snapshot-toolbar history__snapshot-footer";
pagination.append(pane.querySelector(".history__repo-pagination"));
@@ -201,7 +202,7 @@ export const initRepoPanel = (root: HTMLElement, render: (pane: Element, page: n
state.busy = busy;
dateForm.querySelectorAll<HTMLInputElement | HTMLButtonElement>("input, button").forEach(control => control.disabled = busy);
root.setAttribute("aria-busy", String(busy));
- root.querySelectorAll<HTMLButtonElement>("button[data-action], button[data-type=genRepo]").forEach(button => button.disabled = busy);
+ root.querySelectorAll<HTMLButtonElement>("button[data-action], button[data-type=genRepo], button[data-type=fullCheckRepo]").forEach(button => button.disabled = busy);
updateRepoSelection(panes()[0]);
};
root.addEventListener("click", event => {
diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.ts
index cd29968dec..402becbdc6 100644
--- a/app/src/types/api/index.d.ts
+++ b/app/src/types/api/index.d.ts
@@ -934,7 +934,7 @@ export type CreateRiffDeckRequestInput = { "name": string; };
export type CreateSnapshotData = { "created": boolean; "id": string; };
-export type CreateSnapshotRequestInput = { "memo"?: string; };
+export type CreateSnapshotRequestInput = { "fullCheck"?: boolean; "memo"?: string; };
export type CreatedDocumentData = { "document": DocumentPath; "id": string; };
@@ -6673,6 +6673,10 @@ export interface APIPOSTRoutes {
/** 服务器路由要求;资源权限与笔记本租约仍由内核校验 */
authorization?: readonly ["authenticated","admin","writable"];
};
+ /**
+ * 只读检查变更,复用已确认的本机大小及精细时间,记录缺失或变化时读取内容。
+ * 不下载资源或写入缓存;大小和时间完全相同且没有本进程写入标记的外部修改需使用完整校验。
+ */
"/api/repo/checkSnapshot": {
request: EmptyRequestInput;
response: { "code": 0; "data": CheckSnapshotData; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
@@ -6687,6 +6691,10 @@ export interface APIPOSTRoutes {
/** 服务器路由要求;资源权限与笔记本租约仍由内核校验 */
authorization?: readonly ["authenticated","admin","writable"];
};
+ /**
+ * 创建快照;fullCheck 默认为 false,为 true 时读取所有本地已落盘文件核对内容。
+ * 未下载资源沿用其逻辑版本;无变化时返回原快照并令 created 为 false。大文件较多时完整校验耗时更长。
+ */
"/api/repo/createSnapshot": {
request: CreateSnapshotRequestInput;
response: { "code": 0; "data": CreateSnapshotData; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
diff --git a/app/tests/historySnapshots.test.js b/app/tests/historySnapshots.test.js
index e36163f7ab..c42f965ca4 100644
--- a/app/tests/historySnapshots.test.js
+++ b/app/tests/historySnapshots.test.js
@@ -14,7 +14,7 @@ const runCases = async (sources, css, mobile, dark) => {
document.documentElement.dataset.themeMode = dark ? "dark" : "light";
new Function(sources.icons)();
const menu = document.createElement("div");
- window.siyuan = {languages: JSON.parse(sources.languages), dialogs: [], storage: {}, zIndex: 100,
+ window.siyuan = {languages: JSON.parse(sources.languages), config: {sync: {provider: 4}}, dialogs: [], storage: {}, zIndex: 100,
menus: {menu: {element: menu, remove() {}}}};
const toolbar = document.createElement("div");
toolbar.className = `history__snapshots${mobile ? " history__snapshots--mobile" : ""}`;
@@ -55,6 +55,8 @@ const runCases = async (sources, css, mobile, dark) => {
"constants": {Constants: {TIMEOUT_DBLCLICK: 0, TIMEOUT_OPENDIALOG: 0, SIYUAN_ASSETS_IMAGE: [], SIYUAN_ASSETS_AUDIO: [], SIYUAN_ASSETS_VIDEO: []}},
"asset/renderAssets": {renderAssetsPreview: () => ""},
"dialog/confirmDialog": {confirmDialog() {}},
+ "menus/menuToggle": {toggleMenu() {}},
+ "menus/Menu": {MenuItem: class {}},
"protyle/util/onGet": {disabledProtyle() {}, onGet() {}},
"util/pathName": {pathPosix: () => require("node:path").posix},
"util/hostCapabilities": {getHostCapabilities: () => ({importExport: true})},
@@ -93,6 +95,27 @@ const runCases = async (sources, css, mobile, dark) => {
return exports;
};
const {Dialog} = load("dialog");
+ const {initRepoPanel} = load("history/repoPanel");
+ const panel = document.createElement("div");
+ panel.className = "history__repo fn__block";
+ panel.innerHTML = `<div class="history__action"><div class="history__repo-pagination"></div><input class="b3-text-field"><button data-type="compare">Compare</button>${new Function("return `" + sources.snapshotButtons + "`;")()}</div><ul data-type="repoList"></ul>`;
+ document.body.append(panel);
+ const disposePanel = initRepoPanel(panel, () => {});
+ await tick();
+ const local = panel.querySelector('[data-repo-source="local"]');
+ const cloud = panel.querySelector('[data-repo-source="cloud"]');
+ assert.ok(local.querySelector('.history__snapshot-heading [data-type="fullCheckRepo"]'), "full check belongs to local snapshots");
+ assert.equal(cloud.querySelector('[data-type="fullCheckRepo"]'), null, "cloud snapshots must not expose local checks");
+ for (const font of [16, 28]) {
+ panel.style.fontSize = font + "px";
+ await tick();
+ const heading = local.querySelector(".history__snapshot-heading");
+ const button = heading.querySelector('[data-type="fullCheckRepo"]');
+ assert.ok(heading.scrollWidth <= heading.clientWidth + 1, "snapshot controls must wrap on narrow screens");
+ assert.ok(button.getBoundingClientRect().width > 0 && button.getBoundingClientRect().right <= innerWidth + 1, "full check must remain visible");
+ }
+ disposePanel();
+ panel.remove();
const {DocHistorySnapshots} = load("history/docSnapshots");
const {closeNotebookHistoryDialogs} = load("history/notebookDialogs");
const history = new Dialog({title: "项目计划 - 文件历史", width: mobile ? "100vw" : "90vw", height: mobile ? "100dvh" : "80vh",
@@ -185,7 +208,8 @@ if (process.versions.electron && process.type === "browser") {
const ts = require("typescript");
const sass = require("sass");
const sources = {app: path.resolve(__dirname, ".."), icons: fs.readFileSync(path.join(__dirname, "../appearance/icons/litheness/icon.js"), "utf8"), languages: fs.readFileSync(path.join(__dirname, "../appearance/langs/zh-CN.json"), "utf8")};
- for (const name of ["dialog/index", "util/escape", "history/docSnapshots", "history/snapshotDetail", "history/notebookDialogs", "history/repoFile"]) {
+ sources.snapshotButtons = fs.readFileSync(path.join(__dirname, "../src/history/history.ts"), "utf8").match(/<button class="b3-button b3-button--outline" data-type="genRepo">[\s\S]*?data-type="fullCheckRepo">[^<]*<\/button>/)[0];
+ for (const name of ["dialog/index", "util/escape", "history/docSnapshots", "history/snapshotDetail", "history/notebookDialogs", "history/repoFile", "history/repoPanel", "history/repoBatch", "history/repoRange", "history/repoPurge"]) {
sources[name] = ts.transpileModule(fs.readFileSync(path.join(__dirname, "../src", name + ".ts"), "utf8"), {compilerOptions: {module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020}}).outputText;
}
sources["dialog/index"] = require("./fixtures/anchoredInputRuntime.cjs").withAnchoredInputRuntime(sources["dialog/index"]);
diff --git a/kernel/api/repo.go b/kernel/api/repo.go
index 152111bc83..0b5f0279df 100644
--- a/kernel/api/repo.go
+++ b/kernel/api/repo.go
@@ -299,7 +299,7 @@ var removeRepoTagSnapshot = contractHandler(apicontract.RemoveRepoTagSnapshot, f
})
var createSnapshot = contractHandler(apicontract.CreateSnapshot, func(c *gin.Context, request apicontract.CreateSnapshotRequest) apicontract.Response[apicontract.CreateSnapshotData] {
- id, created, err := model.CreateRepoSnapshot(request.Memo)
+ id, created, err := model.CreateRepoSnapshotWithFullCheck(request.Memo, request.FullCheck)
if err != nil {
return apicontract.Failure[apicontract.CreateSnapshotData](-1, fmt.Sprintf(model.Conf.Language(140), err))
}
diff --git a/kernel/api/repo_snapshot_test.go b/kernel/api/repo_snapshot_test.go
index a4fb675404..9aa1895748 100644
--- a/kernel/api/repo_snapshot_test.go
+++ b/kernel/api/repo_snapshot_test.go
@@ -1,17 +1,126 @@
package api
import (
+ "bytes"
"encoding/json"
"net/http"
"net/http/httptest"
+ "os"
+ "path/filepath"
"strings"
"testing"
+ "time"
"github.com/gin-gonic/gin"
+ "github.com/siyuan-note/dejavu"
+ "github.com/siyuan-note/siyuan/kernel/apicontract"
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/model"
+ "github.com/siyuan-note/siyuan/kernel/util"
)
+func TestSnapshotFullCheckHTTP(t *testing.T) {
+ previousConf := model.Conf
+ workspace, data, repoDir := util.WorkspaceDir, util.DataDir, util.RepoDir
+ history, temp, confDir := util.HistoryDir, util.TempDir, util.ConfDir
+ status := util.StatusBarCfg.Load()
+ t.Cleanup(func() {
+ model.Conf = previousConf
+ util.WorkspaceDir, util.DataDir, util.RepoDir = workspace, data, repoDir
+ util.HistoryDir, util.TempDir, util.ConfDir = history, temp, confDir
+ util.StatusBarCfg.Store(status)
+ })
+ root := t.TempDir()
+ util.WorkspaceDir, util.DataDir, util.RepoDir = root, filepath.Join(root, "data"), filepath.Join(root, "repo")
+ util.HistoryDir, util.TempDir, util.ConfDir = filepath.Join(root, "history"), filepath.Join(root, "temp"), filepath.Join(root, "conf")
+ util.StatusBarCfg.Store(&util.StatusBar{MsgDataSyncDisabled: true})
+ model.Conf = model.NewAppConf()
+ model.Conf.Repo.Store(conf.NewRepo())
+ model.Conf.Sync.Store(conf.NewSync())
+ model.Conf.System.Store(conf.NewSystem())
+ model.Conf.System.Load().ID = "snapshot-test"
+ model.Conf.Repo.Load().Key = bytes.Repeat([]byte{17}, 32)
+ model.Conf.Sync.Load().Provider = conf.ProviderLocal
+ model.Conf.Sync.Load().Local = &conf.Local{Endpoint: filepath.Join(root, "cloud")}
+ if err := os.MkdirAll(util.DataDir, 0755); err != nil {
+ t.Fatal(err)
+ }
+ file := filepath.Join(util.DataDir, "probe.txt")
+ stamp := time.Unix(1700000100, 100000000)
+ write := func(content string) {
+ t.Helper()
+ if err := os.WriteFile(file, []byte(content), 0644); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.Chtimes(file, stamp, stamp); err != nil {
+ t.Fatal(err)
+ }
+ }
+ engine := gin.New()
+ const endpoint = "/api/repo/createSnapshot"
+ engine.POST(endpoint, createSnapshot)
+ create := func(body string) apicontract.CreateSnapshotData {
+ t.Helper()
+ recorder := httptest.NewRecorder()
+ engine.ServeHTTP(recorder, httptest.NewRequest(http.MethodPost, endpoint, strings.NewReader(body)))
+ requireAPIContract(t, http.MethodPost, endpoint, recorder)
+ var response struct {
+ Code int `json:"code"`
+ Data apicontract.CreateSnapshotData `json:"data"`
+ }
+ if err := json.Unmarshal(recorder.Body.Bytes(), &response); err != nil || response.Code != 0 {
+ t.Fatalf("snapshot response: %s %v", recorder.Body.String(), err)
+ }
+ return response.Data
+ }
+ write("before")
+ before := create(`{"memo":"before"}`)
+ if !before.Created {
+ t.Fatal("initial snapshot not created")
+ }
+ write("AFTER!")
+ fast := create(`{"memo":"fast","fullCheck":false}`)
+ if fast.Created || fast.ID != before.ID {
+ t.Fatal("fast check did not reuse observations")
+ }
+ full := create(`{"memo":"full","fullCheck":true}`)
+ if !full.Created || full.ID == before.ID {
+ t.Fatal("HTTP full check skipped changed content")
+ }
+ stable := create(`{"fullCheck":true}`)
+ if stable.Created || stable.ID != full.ID {
+ t.Fatal("unchanged full check created a snapshot")
+ }
+ repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, util.HistoryDir, util.TempDir, "snapshot-test", "test", "test", model.Conf.Repo.Load().Key, nil, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, version := range []struct{ id, content string }{{before.ID, "before"}, {full.ID, "AFTER!"}} {
+ index, err := repo.GetIndex(version.id)
+ if err != nil {
+ t.Fatal(err)
+ }
+ files, err := repo.GetFiles(index)
+ if err != nil {
+ t.Fatalf("snapshot file list: %v", err)
+ }
+ found := false
+ for _, file := range files {
+ if file.Path != "/probe.txt" {
+ continue
+ }
+ found = true
+ content, err := repo.OpenFile(file)
+ if err != nil || string(content) != version.content {
+ t.Fatalf("snapshot content %q: %v", content, err)
+ }
+ }
+ if !found {
+ t.Fatal("probe file absent from snapshot")
+ }
+ }
+}
+
func TestSnapshotAPIErrors(t *testing.T) {
original := model.Conf
t.Cleanup(func() { model.Conf = original })
@@ -26,6 +135,8 @@ func TestSnapshotAPIErrors(t *testing.T) {
{"createSnapshot", `{}`},
{"createSnapshot", `{"memo":""}`},
{"createSnapshot", `{"memo":false}`},
+ {"createSnapshot", `{"memo":"check","fullCheck":true}`},
+ {"createSnapshot", `{"fullCheck":"true"}`},
{"checkSnapshot", ``},
{"setSnapshotMemo", `{"id":"invalid","memo":"note"}`},
{"setSnapshotMemo", `{"id":"invalid"}`},
diff --git a/kernel/apicontract/contracts.go b/kernel/apicontract/contracts.go
index 44f77e82ab..0880028eab 100644
--- a/kernel/apicontract/contracts.go
+++ b/kernel/apicontract/contracts.go
@@ -193,7 +193,11 @@ var (
)
var (
- CreateSnapshot = define[CreateSnapshotRequest, CreateSnapshotData]("createSnapshot", "/api/repo/createSnapshot", AuthenticatedAccess|AdminAccess|WritableAccess, JSONBody, ResponseOptions{}, "POST")
+ // CreateSnapshot 创建快照;fullCheck 默认为 false,为 true 时读取所有本地已落盘文件核对内容。
+ // 未下载资源沿用其逻辑版本;无变化时返回原快照并令 created 为 false。大文件较多时完整校验耗时更长。
+ CreateSnapshot = define[CreateSnapshotRequest, CreateSnapshotData]("createSnapshot", "/api/repo/createSnapshot", AuthenticatedAccess|AdminAccess|WritableAccess, JSONBody, ResponseOptions{}, "POST")
+ // CheckSnapshot 只读检查变更,复用已确认的本机大小及精细时间,记录缺失或变化时读取内容。
+ // 不下载资源或写入缓存;大小和时间完全相同且没有本进程写入标记的外部修改需使用完整校验。
CheckSnapshot = define[EmptyRequest, CheckSnapshotData]("checkSnapshot", "/api/repo/checkSnapshot", AuthenticatedAccess|AdminAccess|WritableAccess, NoBody, ResponseOptions{}, "POST")
SetSnapshotMemo = define[SetSnapshotMemoRequest, Null]("setSnapshotMemo", "/api/repo/setSnapshotMemo", AuthenticatedAccess|AdminAccess|WritableAccess, JSONBody, ResponseOptions{}, "POST")
)
diff --git a/kernel/apicontract/repo.go b/kernel/apicontract/repo.go
index e8d21ffcbf..2cce294340 100644
--- a/kernel/apicontract/repo.go
+++ b/kernel/apicontract/repo.go
@@ -10,6 +10,9 @@ import (
type CreateSnapshotRequest struct {
Memo string `json:"memo" api:"optional"`
+ // FullCheck 为 true 时读取全部已落盘文件,检查大小及修改时间均未变化的内容修改。
+ // 默认为 false,复用本机已确认的文件属性;未下载资源保留逻辑版本,不为校验主动下载。
+ FullCheck bool `json:"fullCheck" api:"optional"`
}
type CreateSnapshotData struct {
diff --git a/kernel/apicontract/repo_test.go b/kernel/apicontract/repo_test.go
index 193741fc28..dcb2a7ba24 100644
--- a/kernel/apicontract/repo_test.go
+++ b/kernel/apicontract/repo_test.go
@@ -1,6 +1,7 @@
package apicontract
import (
+ "bytes"
"encoding/json"
"strings"
"testing"
@@ -67,6 +68,21 @@ func TestSnapshotContracts(t *testing.T) {
t.Fatalf("optional memo rejected: %s %v", body, err)
}
}
+ for _, full := range []bool{false, true} {
+ body, err := json.Marshal(map[string]any{"memo": "note", "fullCheck": full})
+ if err != nil {
+ t.Fatal(err)
+ }
+ request, err := CreateSnapshot.Decode(bytes.NewReader(body))
+ if err != nil || request.FullCheck != full {
+ t.Fatalf("full check decoding: %+v %v", request, err)
+ }
+ }
+ for _, body := range []string{`{"fullCheck":null}`, `{"fullCheck":"true"}`, `{"fullCheck":1}`} {
+ if _, err := CreateSnapshot.Decode(strings.NewReader(body)); err == nil {
+ t.Fatalf("invalid full check accepted: %s", body)
+ }
+ }
for _, body := range []string{`{"memo":null}`, `{"memo":1}`, `[]`} {
if _, err := CreateSnapshot.Decode(strings.NewReader(body)); err == nil {
t.Fatalf("invalid memo accepted: %s", body)
diff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.json
index ad27a95cb6..fa97391698 100644
--- a/kernel/apicontract/schema.json
+++ b/kernel/apicontract/schema.json
@@ -22194,6 +22194,9 @@
"CreateSnapshotRequestInput": {
"type": "object",
"properties": {
+ "fullCheck": {
+ "type": "boolean"
+ },
"memo": {
"type": "string"
}
diff --git a/kernel/filesys/tree_mmap_test.go b/kernel/filesys/tree_mmap_test.go
index 66a14afd89..69a46dfc55 100644
--- a/kernel/filesys/tree_mmap_test.go
+++ b/kernel/filesys/tree_mmap_test.go
@@ -8,10 +8,98 @@ import (
"time"
"github.com/siyuan-note/dejavu"
+ "github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
+func TestTreeSameSecondSnapshot(t *testing.T) {
+ for _, encrypted := range []bool{false, true} {
+ t.Run(map[bool]string{false: "plain", true: "encrypted"}[encrypted], func(t *testing.T) {
+ box, root, _, _ := setupStalePathTest(t)
+ originalProvider := DEKProvider
+ originalAcquire, originalRelease := DEKLockAcquire, DEKLockRelease
+ key := bytes.Repeat([]byte{19}, 32)
+ DEKProvider = func(string) ([]byte, error) {
+ if encrypted {
+ return bytes.Clone(key), nil
+ }
+ return nil, nil
+ }
+ DEKLockAcquire, DEKLockRelease = nil, nil
+ t.Cleanup(func() {
+ cache.ClearTreeCache()
+ DEKProvider = originalProvider
+ DEKLockAcquire, DEKLockRelease = originalAcquire, originalRelease
+ })
+ tree := treenode.NewTree(box, "/"+root+".sy", "/Task", "Task")
+ tree.Root.SetIALAttr("custom-deadline", "2026-10-16")
+ if _, err := WriteTree(tree); err != nil {
+ t.Fatal(err)
+ }
+ file := filepath.Join(util.DataDir, box, tree.Path)
+ stamp := time.Unix(1700000100, 100000000)
+ if err := os.Chtimes(file, stamp, stamp); err != nil {
+ t.Fatal(err)
+ }
+ base := t.TempDir()
+ repo, err := dejavu.NewRepo(util.DataDir, filepath.Join(base, "repo"), filepath.Join(base, "history"), filepath.Join(base, "temp"),
+ "device", "device", "test", []byte("0123456789abcdef0123456789abcdef"), nil, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ before, err := repo.Index("before", true, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ original, err := os.ReadFile(file)
+ if err != nil {
+ t.Fatal(err)
+ }
+ tree.Root.SetIALAttr("custom-deadline", "2026-10-15")
+ if _, err = WriteTree(tree); err != nil {
+ t.Fatal(err)
+ }
+ if err = os.Chtimes(file, stamp, stamp); err != nil {
+ t.Fatal(err)
+ }
+ updated, err := os.ReadFile(file)
+ if err != nil || len(original) != len(updated) || bytes.Equal(original, updated) {
+ t.Fatalf("expected equal-size change: %v", err)
+ }
+ after, err := repo.Index("after", true, nil)
+ if err != nil || before.ID == after.ID {
+ t.Fatalf("document change omitted: %v", err)
+ }
+ for _, version := range []struct {
+ id, deadline string
+ content []byte
+ }{
+ {before.ID, "2026-10-16", original}, {after.ID, "2026-10-15", updated},
+ } {
+ if _, _, err = repo.Checkout(version.id, nil); err != nil {
+ t.Fatal(err)
+ }
+ data, err := os.ReadFile(file)
+ if err != nil || !bytes.Equal(data, version.content) {
+ t.Fatalf("snapshot changed source bytes: %v", err)
+ }
+ cache.ClearTreeCache()
+ loaded, err := LoadTree(box, tree.Path, util.NewLute())
+ if err != nil || loaded.Root.IALAttr("custom-deadline") != version.deadline {
+ t.Fatalf("authenticated document recovery: %v", err)
+ }
+ }
+ if encrypted {
+ state, err := os.ReadFile(filepath.Join(repo.Path, "file-state-v1.json"))
+ if err != nil || bytes.Contains(state, []byte("custom-deadline")) || bytes.Contains(state, []byte("2026-10-15")) {
+ t.Fatalf("local state disclosed document contents: %v", err)
+ }
+ }
+ })
+ }
+}
+
func TestTreeAttributeMmapSnapshot(t *testing.T) {
box, root, _, _ := setupStalePathTest(t)
tree := treenode.NewTree(box, "/"+root+".sy", "/Task", "Task")
diff --git a/kernel/go.mod b/kernel/go.mod
index e5b6d25130..c328d03536 100644
--- a/kernel/go.mod
+++ b/kernel/go.mod
@@ -75,7 +75,7 @@ require (
github.com/sashabaranov/go-openai v1.42.0
github.com/shirou/gopsutil/v4 v4.26.7
github.com/siyuan-note/dataparser v0.0.0-20260115084335-b57cb8bc7c17
- github.com/siyuan-note/dejavu v0.0.0-20261022130950-71be2217abb3
+ github.com/siyuan-note/dejavu v0.0.0-20261024125433-e6c364e4ae88
github.com/siyuan-note/encryption v0.0.0-20260715062728-9cb8e9548044
github.com/siyuan-note/eventbus v0.0.0-20260530125927-d77c74260dce
github.com/siyuan-note/filelock v0.0.0-20260831011452-393425122aaa
diff --git a/kernel/go.sum b/kernel/go.sum
index 7ec0c10a4d..96e02b1fd0 100644
--- a/kernel/go.sum
+++ b/kernel/go.sum
@@ -571,6 +571,10 @@ github.com/siyuan-note/dejavu v0.0.0-20261021030846-925a87301674 h1:SLsLvDU9Js7y
github.com/siyuan-note/dejavu v0.0.0-20261021030846-925a87301674/go.mod h1:ixj6rxm+wkjoV8pBDGbuCyfMiPQh3MlxBwHG5OvtEQU=
github.com/siyuan-note/dejavu v0.0.0-20261022130950-71be2217abb3 h1:n35AM98bbsgHX1iUu0P0YmfG/iLKU5kaUHeITpZ5X+U=
github.com/siyuan-note/dejavu v0.0.0-20261022130950-71be2217abb3/go.mod h1:ixj6rxm+wkjoV8pBDGbuCyfMiPQh3MlxBwHG5OvtEQU=
+github.com/siyuan-note/dejavu v0.0.0-20261024124832-dca458f71a76 h1:PbGojPCJzLqTRJhxeXpwrsQhRRfaYSa79nA3N/DaS4Y=
+github.com/siyuan-note/dejavu v0.0.0-20261024124832-dca458f71a76/go.mod h1:ixj6rxm+wkjoV8pBDGbuCyfMiPQh3MlxBwHG5OvtEQU=
+github.com/siyuan-note/dejavu v0.0.0-20261024125433-e6c364e4ae88 h1:O46nhmeuNGJ4U+BafFtP9mQzSD45iM0656tYvQIwtxk=
+github.com/siyuan-note/dejavu v0.0.0-20261024125433-e6c364e4ae88/go.mod h1:ixj6rxm+wkjoV8pBDGbuCyfMiPQh3MlxBwHG5OvtEQU=
github.com/siyuan-note/encryption v0.0.0-20260715062728-9cb8e9548044 h1:b1/Q4DSREDvGh1/NbzR9873EKrjakdoUtsNlghWxUOI=
github.com/siyuan-note/encryption v0.0.0-20260715062728-9cb8e9548044/go.mod h1:t6jXpJdrXzRsdQF+XGaw35f16JVZcDyIkk5/6//ywnY=
github.com/siyuan-note/eventbus v0.0.0-20260530125927-d77c74260dce h1:356bfC3pucxXuYpZIwaQ3viVCbq5RbRuvBhb4xtoBR0=
diff --git a/kernel/model/repository.go b/kernel/model/repository.go
index e3f77cd08a..79394b25c6 100644
--- a/kernel/model/repository.go
+++ b/kernel/model/repository.go
@@ -1880,6 +1880,11 @@ func normalizeSnapshotMemo(memo string) string {
}
func CreateRepoSnapshot(memo string) (id string, created bool, err error) {
+ return CreateRepoSnapshotWithFullCheck(memo, false)
+}
+
+// CreateRepoSnapshotWithFullCheck 允许本次快照核对所有本地已落盘文件的内容。
+func CreateRepoSnapshotWithFullCheck(memo string, fullCheck bool) (id string, created bool, err error) {
if err = checkDataImportRecovery(); err != nil {
return
}
@@ -1914,10 +1919,10 @@ func CreateRepoSnapshot(memo string) (id string, created bool, err error) {
if err = processAssetDownloadRecovery(repo, true); err != nil {
return
}
- index, created, err := repo.IndexWithResult(memo, true, map[string]any{
+ index, created, err := repo.IndexWithResultOptions(memo, true, map[string]any{
eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress,
dejavu.CtxAssetDownloadsAllowed: checkAssetDownloadAccess() == nil,
- })
+ }, dejavu.IndexOptions{FullCheck: fullCheck})
if err != nil {
util.PushStatusBar("Index data repo failed: " + html.EscapeString(err.Error()))
return
diff --git a/kernel/model/repository_snapshot_test.go b/kernel/model/repository_snapshot_test.go
index 38d62ec672..a9e0383f93 100644
--- a/kernel/model/repository_snapshot_test.go
+++ b/kernel/model/repository_snapshot_test.go
@@ -7,11 +7,70 @@ import (
"path/filepath"
"strings"
"testing"
+ "time"
"github.com/siyuan-note/dejavu"
"github.com/siyuan-note/siyuan/kernel/util"
)
+func TestSnapshotFullCheckPreservedAttributes(t *testing.T) {
+ _, partial, _ := prepareAssetDownloadRepoTest(t)
+ file := filepath.Join(util.DataDir, "probe.txt")
+ stamp := time.Unix(1700000100, 100000000)
+ if err := os.WriteFile(file, []byte("before"), 0644); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.Chtimes(file, stamp, stamp); err != nil {
+ t.Fatal(err)
+ }
+ before, _, err := CreateRepoSnapshot("before")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = os.WriteFile(file, []byte("AFTER!"), 0644); err != nil {
+ t.Fatal(err)
+ }
+ if err = os.Chtimes(file, stamp, stamp); err != nil {
+ t.Fatal(err)
+ }
+ fast, created, err := CreateRepoSnapshot("fast")
+ if err != nil || created || fast != before {
+ t.Fatalf("fast check did not reuse file state: %v", err)
+ }
+ after, created, err := CreateRepoSnapshotWithFullCheck("full check", true)
+ if err != nil || !created || after == before {
+ t.Fatalf("full check failed: %v", err)
+ }
+ latest, err := partial.Latest()
+ if err != nil {
+ t.Fatal(err)
+ }
+ files, err := partial.GetFiles(latest)
+ if err != nil {
+ t.Fatal(err)
+ }
+ found := false
+ for _, item := range files {
+ if item.Path == "/probe.txt" {
+ found = true
+ data, err := partial.OpenFile(item)
+ if err != nil || string(data) != "AFTER!" {
+ t.Fatalf("full check content: %q %v", data, err)
+ }
+ }
+ }
+ if !found {
+ t.Fatal("full check omitted the changed file")
+ }
+ stable, created, err := CreateRepoSnapshotWithFullCheck("unchanged full", true)
+ if err != nil || created || stable != after {
+ t.Fatalf("full check failed to converge: %v", err)
+ }
+ if _, err = os.Stat(filepath.Join(util.DataDir, "assets", "file.bin")); !os.IsNotExist(err) {
+ t.Fatalf("full check downloaded deferred resource: %v", err)
+ }
+}
+
func TestSearchRepoSnapshot(t *testing.T) {
_, partial, _ := prepareAssetDownloadRepoTest(t)
index, err := partial.Latest()
diff --git a/kernel/util/preflight_write.go b/kernel/util/preflight_write.go
index 817ef27313..f11e567cc9 100644
--- a/kernel/util/preflight_write.go
+++ b/kernel/util/preflight_write.go
@@ -1,9 +1,11 @@
package util
import (
+ "bytes"
"os"
"github.com/88250/gulu"
+ "github.com/siyuan-note/dejavu"
"github.com/siyuan-note/filelock"
)
@@ -19,15 +21,22 @@ func WriteFileWithPreflight(path string, data []byte, useMmap bool, check func([
if err = check(current); err != nil {
return err
}
+ if current != nil && bytes.Equal(current, data) {
+ return nil
+ }
if useMmap {
file, openErr := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644)
if openErr == nil {
writeErr := writeFileByMmap(file, data)
closeErr := file.Close()
if writeErr == nil && closeErr == nil {
+ dejavu.MarkFileChanged(path)
return nil
}
}
}
- return gulu.File.WriteFileSafer(path, data, 0644)
+ if err = gulu.File.WriteFileSafer(path, data, 0644); err == nil {
+ dejavu.MarkFileChanged(path)
+ }
+ return err
}
diff --git a/kernel/util/preflight_write_test.go b/kernel/util/preflight_write_test.go
index 7880f02bbf..6500f911cd 100644
--- a/kernel/util/preflight_write_test.go
+++ b/kernel/util/preflight_write_test.go
@@ -8,9 +8,66 @@ import (
"testing"
"time"
+ "github.com/siyuan-note/dejavu"
"github.com/siyuan-note/filelock"
)
+func TestPreflightWriteMarksSnapshotChanges(t *testing.T) {
+ for _, mapped := range []bool{false, true} {
+ base := t.TempDir()
+ dataDir := filepath.Join(base, "data")
+ if err := os.MkdirAll(dataDir, 0755); err != nil {
+ t.Fatal(err)
+ }
+ name := filepath.Join(dataDir, "source.txt")
+ stamp := time.Unix(1700000100, 100000000)
+ if err := os.WriteFile(name, []byte("before"), 0644); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.Chtimes(name, stamp, stamp); err != nil {
+ t.Fatal(err)
+ }
+ repo, err := dejavu.NewRepo(dataDir, filepath.Join(base, "repo"), filepath.Join(base, "history"), filepath.Join(base, "temp"),
+ "device", "device", "test", []byte("0123456789abcdef0123456789abcdef"), nil, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ before, err := repo.Index("before", true, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = WriteFileWithPreflight(name, []byte("AFTER!"), mapped, func([]byte) error { return nil }); err != nil {
+ t.Fatal(err)
+ }
+ if err = os.Chtimes(name, stamp, stamp); err != nil {
+ t.Fatal(err)
+ }
+ changed, err := repo.CheckSnapshot()
+ if err != nil || !changed {
+ t.Fatalf("known same-attribute write missed: %v", err)
+ }
+ after, err := repo.Index("after", true, nil)
+ if err != nil || before.ID == after.ID {
+ t.Fatalf("known write not indexed: %v", err)
+ }
+ files, err := repo.GetFiles(after)
+ if err != nil || len(files) != 1 {
+ t.Fatalf("snapshot files: %v", err)
+ }
+ content, err := repo.OpenFile(files[0])
+ if err != nil || string(content) != "AFTER!" {
+ t.Fatalf("snapshot content %q: %v", content, err)
+ }
+ if err = WriteFileWithPreflight(name, []byte("AFTER!"), mapped, func([]byte) error { return nil }); err != nil {
+ t.Fatal(err)
+ }
+ stable, created, err := repo.IndexWithResult("unchanged", true, nil)
+ if err != nil || created || stable.ID != after.ID {
+ t.Fatalf("unchanged write made a version: %v", err)
+ }
+ }
+}
+
func TestPreflightWritePreservesRejectedSource(t *testing.T) {
for _, mapped := range []bool{false, true} {
name := filepath.Join(t.TempDir(), "source.sy")