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.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user