fix: avoid outgoing ops during remote template apply
This commit is contained in:
parent
0c0b0d98c7
commit
e2aad19cc4
|
|
@ -207,7 +207,6 @@ func (a *App) ensureTemplateChildren(nodeID, templateID, parentFsPath, title str
|
||||||
_ = os.MkdirAll(fullPath, 0o755)
|
_ = os.MkdirAll(fullPath, 0o755)
|
||||||
|
|
||||||
_ = a.activity.Record(nodeID, activity.TargetFolder, childNode.ID, "", activity.TypeNodeCreated, folderName, "")
|
_ = 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 {
|
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 (?,?,?)`,
|
`INSERT OR IGNORE INTO notes (node_id, file_id, format) VALUES (?,?,?)`,
|
||||||
childNode.ID, fileID, "markdown")
|
childNode.ID, fileID, "markdown")
|
||||||
_ = a.activity.Record(nodeID, activity.TargetNote, childNode.ID, "", activity.TypeNoteCreated, fileTitle, "")
|
_ = 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -631,11 +618,11 @@ func (a *App) moveNodeFiles(n *nodes.Node, newParentID, now string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
type fileMove struct {
|
type fileMove struct {
|
||||||
id string
|
id string
|
||||||
oldPath string
|
oldPath string
|
||||||
oldAbs string
|
oldAbs string
|
||||||
newRelPath string
|
newRelPath string
|
||||||
newAbs string
|
newAbs string
|
||||||
}
|
}
|
||||||
var fileMoves []fileMove
|
var fileMoves []fileMove
|
||||||
frows, ferr := a.db.Query(`SELECT id, path FROM files WHERE node_id=?`, n.ID)
|
frows, ferr := a.db.Query(`SELECT id, path FROM files WHERE node_id=?`, n.ID)
|
||||||
|
|
|
||||||
|
|
@ -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 ---
|
// --- helpers ---
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue