Skip to content

Commit

Permalink
Fix trigger creation for copied note (#4488)
Browse files Browse the repository at this point in the history
  • Loading branch information
nono authored Nov 13, 2024
2 parents f626f40 + a4665a8 commit 575c6aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion model/note/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ func CopyFile(inst *instance.Instance, olddoc, newdoc *vfs.FileDoc) error {
if cerr := file.Close(); cerr != nil && err == nil {
err = cerr
}
return err
if err != nil {
return err
}
return SetupTrigger(inst, newdoc.ID())
}

func updateProsemirrorImageURLs(node *model.Node, mapping map[string]*Image) {
Expand Down
6 changes: 3 additions & 3 deletions model/note/note.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func writeFile(inst *instance.Instance, doc *Document, oldDoc *vfs.FileDoc) (fil
if oldDoc == nil {
fileDoc, err = newFileDoc(inst, doc)
if err != nil {
return
return nil, err
}
} else {
fileDoc = doc.asFile(inst, oldDoc)
Expand Down Expand Up @@ -403,7 +403,7 @@ func writeFile(inst *instance.Instance, doc *Document, oldDoc *vfs.FileDoc) (fil
if err == nil {
break
} else if !errors.Is(err, os.ErrExist) {
return
return nil, err
}
filename := strings.TrimSuffix(path.Base(basename), path.Ext(basename))
fileDoc.DocName = fmt.Sprintf("%s (%d).cozy-note", filename, i)
Expand All @@ -421,7 +421,7 @@ func writeFile(inst *instance.Instance, doc *Document, oldDoc *vfs.FileDoc) (fil
_ = saveToCache(inst, doc)
}
}
return
return fileDoc, err
}

// forceRename will update the FileDoc in CouchDB with the new name (but the
Expand Down

0 comments on commit 575c6aa

Please sign in to comment.