fix: avoid outgoing ops during remote template apply

This commit is contained in:
mirivlad 2026-06-04 03:36:44 +08:00
parent 0c0b0d98c7
commit e2aad19cc4
2 changed files with 13 additions and 18 deletions

View File

@ -207,7 +207,6 @@ func (a *App) ensureTemplateChildren(nodeID, templateID, parentFsPath, title str
_ = os.MkdirAll(fullPath, 0o755)
_ = a.activity.Record(nodeID, activity.TargetFolder, childNode.ID, "", activity.TypeNodeCreated, folderName, "")
_ = a.sync.RecordOp(syncsvc.EntityFolder, childNode.ID, syncsvc.OpCreate, nodePayload(childNode))
}
for _, df := range tmpl.DefaultFiles {
@ -245,18 +244,6 @@ func (a *App) ensureTemplateChildren(nodeID, templateID, parentFsPath, title str
`INSERT OR IGNORE INTO notes (node_id, file_id, format) VALUES (?,?,?)`,
childNode.ID, fileID, "markdown")
_ = a.activity.Record(nodeID, activity.TargetNote, childNode.ID, "", activity.TypeNoteCreated, fileTitle, "")
_ = a.sync.RecordOp(syncsvc.EntityNote, childNode.ID, syncsvc.OpCreate, map[string]interface{}{
"node_id": childNode.ID,
"parent_id": nodeID,
"title": fileTitle,
"file_id": fileID,
"format": "markdown",
"content": content,
"filename": filepath.Base(fpath),
"path": relPath,
"created_at": nowRFC,
"updated_at": nowRFC,
})
}
return nil
}
@ -631,11 +618,11 @@ func (a *App) moveNodeFiles(n *nodes.Node, newParentID, now string) error {
}
type fileMove struct {
id string
oldPath string
oldAbs string
newRelPath string
newAbs string
id string
oldPath string
oldAbs string
newRelPath string
newAbs string
}
var fileMoves []fileMove
frows, ferr := a.db.Query(`SELECT id, path FROM files WHERE node_id=?`, n.ID)

View File

@ -1448,6 +1448,14 @@ func TestVaultLayout_TemplateChildrenBackwardCompat(t *testing.T) {
}
}
}
ops, err := app.sync.GetUnpushedOps()
if err != nil {
t.Fatalf("get unpushed ops: %v", err)
}
if len(ops) != 0 {
t.Fatalf("remote template apply recorded %d outgoing sync ops, want 0", len(ops))
}
}
// --- helpers ---