aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/mbf
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-07-09 09:30:56 +0900
committerOphestra <cat@gensokyo.uk>2026-07-09 09:34:27 +0900
commit2f1534853a187018b94754e5ae2f009d7c2ae347 (patch)
tree2ef558652e55a7f35eabf38a55140b2be0f8692d /cmd/mbf
parent3f8e111d1c96da034ea31846d46ae1fe4bf9f93c (diff)
internal/pkg: consolidate cache attributes
This makes the interface stable. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/mbf')
-rw-r--r--cmd/mbf/cache.go15
-rw-r--r--cmd/mbf/daemon_test.go2
-rw-r--r--cmd/mbf/main.go8
3 files changed, 11 insertions, 14 deletions
diff --git a/cmd/mbf/cache.go b/cmd/mbf/cache.go
index aea54546..7134e5d2 100644
--- a/cmd/mbf/cache.go
+++ b/cmd/mbf/cache.go
@@ -21,7 +21,7 @@ type cache struct {
// Should generally not be used directly.
c *pkg.Cache
- cures, jobs int
+ attr pkg.CacheAttr
// Primarily to work around missing landlock LSM.
hostAbstract bool
// Set SCHED_IDLE.
@@ -49,18 +49,17 @@ func (cache *cache) open() (err error) {
return
}
- var flags int
if cache.idle {
- flags |= pkg.CSchedIdle
+ cache.attr.Flags |= pkg.CSchedIdle
}
if cache.hostAbstract {
- flags |= pkg.CHostAbstract
+ cache.attr.Flags |= pkg.CHostAbstract
}
if !cache.verboseInit {
- flags |= pkg.CSuppressInit
+ cache.attr.Flags |= pkg.CSuppressInit
}
if !cache.deep {
- flags |= pkg.CExternShallow
+ cache.attr.Flags |= pkg.CExternShallow
}
done := make(chan struct{})
@@ -82,10 +81,8 @@ func (cache *cache) open() (err error) {
cache.c, err = pkg.Open(
cache.ctx,
cache.msg,
- flags,
- cache.cures,
- cache.jobs,
base,
+ &cache.attr,
)
if err != nil {
return
diff --git a/cmd/mbf/daemon_test.go b/cmd/mbf/daemon_test.go
index 7b825d0b..5d4bbdfc 100644
--- a/cmd/mbf/daemon_test.go
+++ b/cmd/mbf/daemon_test.go
@@ -28,8 +28,8 @@ func TestNoReply(t *testing.T) {
c, err := pkg.Open(
t.Context(),
message.New(log.New(os.Stderr, "cir: ", 0)),
- 0, 0, 0,
check.MustAbs(t.TempDir()),
+ nil,
)
if err != nil {
t.Fatalf("Open: error = %v", err)
diff --git a/cmd/mbf/main.go b/cmd/mbf/main.go
index b0f5495a..f3ca4eba 100644
--- a/cmd/mbf/main.go
+++ b/cmd/mbf/main.go
@@ -203,11 +203,11 @@ func main() {
"v", command.BoolFlag(false),
"Do not suppress verbose output from init",
).Flag(
- &cm.cures,
+ &cm.attr.Cures,
"cures", command.IntFlag(0),
"Maximum number of dependencies to cure at any given time",
).Flag(
- &cm.jobs,
+ &cm.attr.Jobs,
"jobs", command.IntFlag(0),
"Preferred number of jobs to run, when applicable",
).Flag(
@@ -934,8 +934,8 @@ func main() {
return fmt.Errorf("unknown artifact %q", args[1])
}
- if !a.IsExclusive() && cm.jobs < 1 {
- cm.jobs = runtime.NumCPU()/n + 1
+ if !a.IsExclusive() && cm.attr.Jobs < 1 {
+ cm.attr.Jobs = runtime.NumCPU()/n + 1
}
res := make([]unique.Handle[pkg.Checksum], n)