Skip to content

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

:bug: Fix database bind block https://ld246.com/article/1719117529369

Daniel65f24b376ee9
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json
index 3f424b13da..4dd57d9229 100644
--- a/app/appearance/langs/en_US.json
+++ b/app/appearance/langs/en_US.json
@@ -1528,7 +1528,7 @@
"239": "Related operations are being processed, please try again later",
"240": "The current drag-and-drop heading is located in the container block and the drag-and-drop operation cannot be performed",
"241": "Drag to its subheading is not supported",
- "242": "The binding block already exists in the current database",
+ "242": "TODO",
"243": "Only list the first [%d] tags (including subtags), if you need to adjust, please modify [Settings - Doc Tree - Maximum number to list]",
"244": "It did not exit normally after the last use. It is recommended to execute [Doc Tree - Rebuild Index]. In the future, please exit the program completely before shutting down the computer",
"245": "It did not exit normally after the last use. It is recommended to execute [Doc Tree - Rebuild Index]. In the future, please use [Exit Application] in the right panel to exit normally",
diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json
index 4a2299803b..1b173ed212 100644
--- a/app/appearance/langs/es_ES.json
+++ b/app/appearance/langs/es_ES.json
@@ -1528,7 +1528,7 @@
"239": "Las operaciones relacionadas se están procesando, inténtalo de nuevo más tarde",
"240": "El encabezado actual de arrastrar y soltar está ubicado en el bloque contenedor y la operación de arrastrar y soltar no se puede realizar",
"241": "No se admite arrastrar a su subtítulo",
- "242": "El bloque de enlace ya existe en la base de datos actual",
+ "242": "TODO",
"243": "Enumere solo las primeras [%d] etiquetas (incluidas las subetiquetas), modifique [Configuración - Árbol de documentos - Número máximo a listar]",
"244": "No salió normalmente después del último uso. Se recomienda ejecutar [Árbol de documentos - Reconstruir índice]. En el futuro, salga del programa por completo antes de apagar la computadora",
"245": "No salió normalmente después del último uso. Se recomienda ejecutar [Árbol de documentos - Reconstruir índice]. En el futuro, utilice [Salir de la aplicación] en el panel derecho para salir normalmente",
diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json
index bd619e8e27..8e1213085d 100644
--- a/app/appearance/langs/fr_FR.json
+++ b/app/appearance/langs/fr_FR.json
@@ -1528,7 +1528,7 @@
"239": "Les opérations associées sont en cours de traitement, veuillez réessayer plus tard",
"240": "L'en-tête du glisser-déposer actuel se trouve dans le bloc conteneur et l'opération de glisser-déposer ne peut pas être effectuée",
"241": "Le glisser vers son sous-titre n'est pas pris en charge",
- "242": "Le bloc de liaison existe déjà dans la base de données actuelle",
+ "242": "TODO",
"243": "Répertorier uniquement les [%d] premières balises (y compris les sous-balises). veuillez modifier [Paramètres - Arbre des documents - Nombre maximum de documents à lister].",
"244": "Il ne s'est pas terminé normalement après la dernière utilisation. Il est recommandé d'exécuter [Doc Tree - Reconstruire l'index]. À l'avenir, veuillez quitter complètement le programme avant d'éteindre l'ordinateur",
"245": "Il ne s'est pas terminé normalement après la dernière utilisation. Il est recommandé d'exécuter [Doc Tree - Reconstruire l'index]. À l'avenir, veuillez utiliser [Quitter l'application] dans le panneau de droite pour quitter normalement",
diff --git a/app/appearance/langs/ja_JP.json b/app/appearance/langs/ja_JP.json
index dc02d91fcf..fe21964c6e 100644
--- a/app/appearance/langs/ja_JP.json
+++ b/app/appearance/langs/ja_JP.json
@@ -1528,7 +1528,7 @@
"239": "関連する操作が処理中です。後でまた試してください",
"240": "コンテナブロック内の見出しは移動できません",
"241": "小見出しへのドラッグはサポートされていません",
- "242": "現在のデータベースにはすでにバインディングブロックが存在します",
+ "242": "TODO",
"243": "最初の [%d] 個のタグ (サブタグを含む) のみを表示します。調整が必要な場合は [設定] - [ドキュメントツリー] - [リストする最大数] を変更してください",
"244": "前回の使用後に正常に終了しませんでした。[ドキュメントツリー] - [インデックスの再構築] を実行することをお勧めします。今後はコンピュータをシャットダウンする前にプログラムを完全に終了してください",
"245": "前回の使用後に正常に終了しませんでした。[ドキュメントツリー] - [インデックスの再構築] を実行することをお勧めします。今後は右パネルの [アプリケーションの終了] を使用して終了してください",
diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json
index 073fe28ca2..3b3d32d9c1 100644
--- a/app/appearance/langs/zh_CHT.json
+++ b/app/appearance/langs/zh_CHT.json
@@ -1528,7 +1528,7 @@
"239": "相關操作正在處理中,請稍後再試",
"240": "目前拖曳標題位於容器區塊中,無法進行拖曳操作",
"241": "不支持拖曳為自己的子標題",
- "242": "目前資料庫中已經存在該綁定區塊",
+ "242": "TODO",
"243": "僅列出前 [%d] 個標籤(含子標籤),如需調整請修改 [設置 - 文檔樹 - 最大列出數量]",
"244": "上次使用後未正常退出,建議執行一次 [文檔樹 - 重建索引]。以後請完整退出程式後再關閉電腦",
"245": "上次使用後未正常退出,建議執行一次 [文檔樹 - 重建索引]。以後請使用右側欄面板中的 [退出應用] 進行正常退出",
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index a28ec8c9e6..7229fdcec2 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -1528,7 +1528,7 @@
"239": "相关操作正在处理中,请稍后再试",
"240": "当前拖拽标题位于容器块中,无法进行拖拽操作",
"241": "不支持拖拽为自己的子标题",
- "242": "当前数据库中已经存在该绑定块",
+ "242": "TODO",
"243": "仅列出前 [%d] 个标签(含子标签),如需调整请修改 [设置 - 文档树 - 最大列出数量]",
"244": "上次使用后未正常退出,建议执行一次 [文档树 - 重建索引]。以后请完整退出程序后再关闭电脑",
"245": "上次使用后未正常退出,建议执行一次 [文档树 - 重建索引]。以后请使用右侧栏面板中的 [退出应用] 进行正常退出",
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 9bdcb0f14a..1b1736f5ab 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -2826,16 +2826,23 @@ func replaceAttributeViewBlock(operation *Operation, tx *Transaction) (err error
}
var node *ast.Node
+ var tree *parse.Tree
if !operation.IsDetached {
- node, _, _ = getNodeByBlockID(tx, operation.NextID)
+ node, tree, _ = getNodeByBlockID(tx, operation.NextID)
}
- // 检查是否已经存在绑定块
- // Improve database primary key binding block https://github.com/siyuan-note/siyuan/issues/10945
+ now := util.CurrentTimeMillis()
+ // 检查是否已经存在绑定块,如果存在的话则重新绑定
for _, keyValues := range attrView.KeyValues {
for _, value := range keyValues.Values {
if value.BlockID == operation.NextID {
- util.PushMsg(Conf.language(242), 3000)
+ if !operation.IsDetached {
+ bindBlockAv0(tx, operation.AvID, node, tree)
+ value.IsDetached = false
+ value.Block.Content = getNodeRefText(node)
+ value.UpdatedAt = now
+ err = av.SaveAttributeView(attrView)
+ }
return
}
}