ADR 0627 §2: a refusal for want of room is told from the others, so a holder's finding for it can clear
A holder raises a finding when it refuses a file for want of room; that finding is the holder's, not the file's, and clears once it takes a file again. AtCap and RefusedAtCap let it tell that refusal apart without its own copy of the reason's words. Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
+8
-1
@@ -93,6 +93,13 @@ type Received struct {
|
||||
Ended bool
|
||||
}
|
||||
|
||||
// AtCap opens the reason of a refusal for want of room: the objects would pass their cap. A holder tells it from
|
||||
// the other refusals with RefusedAtCap, so the finding it raises for it can clear once it takes a file again.
|
||||
const AtCap = "the objects are at their cap"
|
||||
|
||||
// RefusedAtCap says whether a refusal's reason is one for want of room (AtCap).
|
||||
func RefusedAtCap(reason string) bool { return strings.HasPrefix(reason, AtCap) }
|
||||
|
||||
// Receiver takes transfers in parts into a holder's own objects.
|
||||
type Receiver[M any] struct {
|
||||
Objects Objects
|
||||
@@ -182,7 +189,7 @@ func (r *Receiver[M]) Open(id, opener string, parts []Want, shape M) (Received,
|
||||
size += uint64(max(p.Size, 0))
|
||||
}
|
||||
if used+size > r.Cap {
|
||||
return Received{ID: id, Ended: true}, r.refuse(t, fmt.Sprintf("the objects are at their cap of %d bytes (%d held, %d asked)", r.Cap, used, size))
|
||||
return Received{ID: id, Ended: true}, r.refuse(t, fmt.Sprintf(AtCap+" of %d bytes (%d held, %d asked)", r.Cap, used, size))
|
||||
}
|
||||
if r.Holds != nil {
|
||||
for _, p := range parts {
|
||||
|
||||
@@ -186,6 +186,9 @@ func TestAHolderTakesAFileInParts(t *testing.T) {
|
||||
if got := pkgLog[len(pkgLog)-1].outcome; !strings.HasPrefix(got, "refused: the objects are at their cap") {
|
||||
t.Errorf("the cap's refusal said %q", got)
|
||||
}
|
||||
if !RefusedAtCap(strings.TrimPrefix(pkgLog[len(pkgLog)-1].outcome, "refused: ")) || RefusedAtCap(strings.TrimPrefix(pkgLog[len(pkgLog)-2].outcome, "refused: ")) {
|
||||
t.Errorf("RefusedAtCap tells the cap's refusal from the check's: %q, %q", pkgLog[len(pkgLog)-1].outcome, pkgLog[len(pkgLog)-2].outcome)
|
||||
}
|
||||
if got := pkgLog[len(pkgLog)-2].outcome; got != "refused: the builder did not number it" {
|
||||
t.Errorf("the check's refusal said %q", got)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user