diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-21 00:18:50 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-21 00:18:50 +0900 |
| commit | 5d8a2199b6c8dc5f75b529a39d196c6cb14c98c2 (patch) | |
| tree | 5ad693466483081342b24df929365490015b4efa /container/initplace.go | |
| parent | a1482ecdd0f98728f4b97137cd7b2fa17f67bb89 (diff) | |
container/init: op interface valid method
Check ops early and eliminate duplicate checks.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/initplace.go')
| -rw-r--r-- | container/initplace.go | 8 |
1 files changed, 3 insertions, 5 deletions
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" } |
