Skip to content

Commit

Permalink
Fix trigger creation for copied note
Browse files Browse the repository at this point in the history
  • Loading branch information
nono committed Nov 12, 2024
1 parent f626f40 commit a4665a8
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 a4665a8

Please sign in to comment.