system: update doc commands and remove mutex
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m8s
Test / Hakurei (push) Successful in 2m59s
Test / Hpkg (push) Successful in 3m56s
Test / Sandbox (race detector) (push) Successful in 4m28s
Test / Hakurei (race detector) (push) Successful in 5m4s
Test / Flake checks (push) Successful in 1m21s

The mutex is not really doing anything, none of these methods make sense when called concurrently anyway. The copylocks analysis is still satisfied by the noCopy struct.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-09-02 04:54:34 +09:00
parent 3acf49f979
commit aab806a6f9
20 changed files with 210 additions and 210 deletions

View File

@@ -6,38 +6,30 @@ import (
"os"
)
// Ensure the existence and mode of a directory.
// Ensure appends [MkdirOp] to [I] with its [Enablement] ignored.
func (sys *I) Ensure(name string, perm os.FileMode) *I {
sys.lock.Lock()
defer sys.lock.Unlock()
sys.ops = append(sys.ops, &Mkdir{User, name, perm, false})
sys.ops = append(sys.ops, &MkdirOp{User, name, perm, false})
return sys
}
// Ephemeral ensures the temporary existence and mode of a directory through the life of et.
// Ephemeral appends an ephemeral [MkdirOp] to [I].
func (sys *I) Ephemeral(et Enablement, name string, perm os.FileMode) *I {
sys.lock.Lock()
defer sys.lock.Unlock()
sys.ops = append(sys.ops, &Mkdir{et, name, perm, true})
sys.ops = append(sys.ops, &MkdirOp{et, name, perm, true})
return sys
}
type Mkdir struct {
// MkdirOp ensures the existence of a directory.
// For ephemeral, the directory is destroyed once [Enablement] is no longer satisfied.
type MkdirOp struct {
et Enablement
path string
perm os.FileMode
ephemeral bool
}
func (m *Mkdir) Type() Enablement {
return m.et
}
func (m *MkdirOp) Type() Enablement { return m.et }
func (m *Mkdir) apply(*I) error {
func (m *MkdirOp) apply(*I) error {
msg.Verbose("ensuring directory", m)
// create directory
@@ -52,7 +44,7 @@ func (m *Mkdir) apply(*I) error {
}
}
func (m *Mkdir) revert(_ *I, ec *Criteria) error {
func (m *MkdirOp) revert(_ *I, ec *Criteria) error {
if !m.ephemeral {
// skip non-ephemeral dir and do not log anything
return nil
@@ -67,16 +59,14 @@ func (m *Mkdir) revert(_ *I, ec *Criteria) error {
}
}
func (m *Mkdir) Is(o Op) bool {
m0, ok := o.(*Mkdir)
return ok && m0 != nil && *m == *m0
func (m *MkdirOp) Is(o Op) bool {
target, ok := o.(*MkdirOp)
return ok && m != nil && target != nil && *m == *target
}
func (m *Mkdir) Path() string {
return m.path
}
func (m *MkdirOp) Path() string { return m.path }
func (m *Mkdir) String() string {
func (m *MkdirOp) String() string {
t := "ensure"
if m.ephemeral {
t = TypeString(m.Type())