From af952807c7a30482c493328d5a5d0db0171fdc5d Mon Sep 17 00:00:00 2001 From: andrigamerita <37557992+andrigamerita@users.noreply.github.com> Date: Fri, 19 Jul 2024 01:14:31 +0200 Subject: [PATCH] feat: write memo UID in file names when exporting to Markdown (#3712) When using the "export to Markdown" feature in Memos, the files included in the ZIP folder don't feature any kind of reference to their alphanumeric UID from the server's database, which completely breaks the point of links inside the files made with the `[[memos/]]` format, since it's impossible to know which Markdown file this kind of string inside other files refers to. This pull request modifies the ExportMemos server function, to add the UID of every memo immediately after the date in the filename. For example, an exported memo would now be called: `YYYY-MM-DDThh:mm:ss+hh:mm-AbcDefGhiJklMnoPqrStu1-PUBLIC.md`. --- server/router/api/v1/memo_service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/router/api/v1/memo_service.go b/server/router/api/v1/memo_service.go index 58db8194..9f2196e2 100644 --- a/server/router/api/v1/memo_service.go +++ b/server/router/api/v1/memo_service.go @@ -601,7 +601,7 @@ func (s *APIV1Service) ExportMemos(ctx context.Context, request *v1pb.ExportMemo if err != nil { return nil, errors.Wrap(err, "failed to convert memo") } - file, err := writer.Create(time.Unix(memo.CreatedTs, 0).Format(time.RFC3339) + "-" + string(memo.Visibility) + ".md") + file, err := writer.Create(time.Unix(memo.CreatedTs, 0).Format(time.RFC3339) + "-" + memo.UID + "-" + string(memo.Visibility) + ".md") if err != nil { return nil, status.Errorf(codes.Internal, "Failed to create memo file") }