Merge pull request 'Forge rights read as the user sees them; write-only grant for mesh-tools; progress answers in minimal detail (issues 1945, 1947)' (#509) from fix/progress-and-unwritable into main
This commit was merged in pull request #509.
This commit is contained in:
@@ -168,6 +168,8 @@ func (k *KB) Progress(a ProgressAsk) (*Progress, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// A cut takes the warnings from the last: the calls that failed are said before the answers that did not parse.
|
||||
callsFirst(p.Warnings)
|
||||
fitProgress(p, boundOf(a.Bound))
|
||||
return p, nil
|
||||
}
|
||||
@@ -835,8 +837,21 @@ func movedSay(t *time.Time) string {
|
||||
return " · moved " + when(t)
|
||||
}
|
||||
|
||||
// callsFirst puts the warnings of calls that failed before those of answers that did not parse, in place.
|
||||
func callsFirst(w []string) {
|
||||
sort.SliceStable(w, func(i, j int) bool {
|
||||
return !strings.Contains(w[i], " answered something else") && strings.Contains(w[j], " answered something else")
|
||||
})
|
||||
}
|
||||
|
||||
// fitProgress keeps an answer within its bound: the items go first, then the tree's last lines, saying what was cut.
|
||||
// A minimal answer never carries the items: its tree says the same, one line per milestone, so leaving them out is how
|
||||
// the minimal form is made (the items of design 47 alone passed 8192 bytes) and no cut. A detailed answer's items, and
|
||||
// everything else that goes, are said in cut.
|
||||
func fitProgress(p *Progress, bound int) {
|
||||
if p.Detail == DetailMinimal && p.Tree != "" {
|
||||
p.Items = nil
|
||||
}
|
||||
if size(p) <= bound {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user