From 5d8a2199b6c8dc5f75b529a39d196c6cb14c98c2 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Thu, 21 Aug 2025 00:18:50 +0900 Subject: container/init: op interface valid method Check ops early and eliminate duplicate checks. Signed-off-by: Ophestra --- container/initplace.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'container/initplace.go') diff --git a/container/initplace.go b/container/initplace.go index 91146948..2d98d94f 100644 --- a/container/initplace.go +++ b/container/initplace.go @@ -35,12 +35,9 @@ type TmpfileOp struct { Data []byte } +func (t *TmpfileOp) Valid() bool { return t != nil && t.Path != nil } func (t *TmpfileOp) early(*setupState) error { return nil } func (t *TmpfileOp) apply(state *setupState) error { - if t.Path == nil { - return EBADE - } - var tmpPath string if f, err := os.CreateTemp(FHSRoot, intermediatePatternTmpfile); err != nil { return wrapErrSelf(err) @@ -72,7 +69,8 @@ func (t *TmpfileOp) apply(state *setupState) error { func (t *TmpfileOp) Is(op Op) bool { vt, ok := op.(*TmpfileOp) - return ok && t.Path != nil && vt.Path != nil && t.Path.Is(vt.Path) && + return ok && t.Valid() && vt.Valid() && + t.Path.Is(vt.Path) && string(t.Data) == string(vt.Data) } func (*TmpfileOp) prefix() string { return "placing" } -- cgit v1.3.1