MCPcopy Index your code
hub / github.com/dnote/dnote / GetTmpContentPath

Function GetTmpContentPath

pkg/cli/ui/editor.go:33–46  ·  view source on GitHub ↗

GetTmpContentPath returns the path to the temporary file containing content being added or edited

(ctx context.DnoteCtx)

Source from the content-addressed store, hash-verified

31// GetTmpContentPath returns the path to the temporary file containing
32// content being added or edited
33func GetTmpContentPath(ctx context.DnoteCtx) (string, error) {
34 for i := 0; ; i++ {
35 filename := fmt.Sprintf("%s_%d.%s", consts.TmpContentFileBase, i, consts.TmpContentFileExt)
36 candidate := fmt.Sprintf("%s/%s", ctx.Paths.Cache, filename)
37
38 ok, err := utils.FileExists(candidate)
39 if err != nil {
40 return "", errors.Wrapf(err, "checking if file exists at %s", candidate)
41 }
42 if !ok {
43 return candidate, nil
44 }
45 }
46}
47
48// getEditorCommand returns the system's editor command with appropriate flags,
49// if necessary, to make the command wait until editor is close to exit.

Callers 4

getContentFunction · 0.92
waitEditorBookNameFunction · 0.92
waitEditorNoteContentFunction · 0.92
TestGetTmpContentPathFunction · 0.85

Calls 1

FileExistsFunction · 0.92

Tested by 1

TestGetTmpContentPathFunction · 0.68