From 48e394146bc7ad313ba93e14f4f40eacd4dbf5b2 Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 13 Nov 2026 19:45:24 +0800 Subject: [PATCH] davsync: the setup text's body regexp is compiled when first used (#6534) d21cb563e compiled setupBody at launch, so TestNoEagerPackageRegexps was red on main. It is a lazyre.New now, as every other package-level regexp. Run (mica): go vet ./internal/davsync; go test -count=1 -run TestNoEagerPackageRegexps . ok; go test -count=1 ./internal/davsync ok. --- internal/davsync/setuptext.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/davsync/setuptext.go b/internal/davsync/setuptext.go index 4e7112898..abb1b0627 100644 --- a/internal/davsync/setuptext.go +++ b/internal/davsync/setuptext.go @@ -4,10 +4,10 @@ import ( "encoding/base64" "encoding/json" "errors" - "regexp" "strings" "github.com/yetone/magpie/internal/backup" + "github.com/yetone/magpie/internal/lazyre" ) // SetupPrefix begins a sync setup copied as text (WJaunita45604 on X: one @@ -70,7 +70,7 @@ func SetupText() (string, error) { // setupBody is the setup's text after its prefix, to the first character // that can't be in it: line breaks and spaces a chat or a mail wrapped it // with are in it, and taken out after. -var setupBody = regexp.MustCompile(`^[A-Za-z0-9_\-+/=\s]*`) +var setupBody = lazyre.New(`^[A-Za-z0-9_\-+/=\s]*`) // OpenSetupText opens what SetupText gave, with the passphrase it was sealed // with. Text before the setup, and line breaks a chat put in it, are skipped.