diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-01-07 00:04:32 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-01-07 00:04:32 +0900 |
| commit | 45301559bf4df313fef6894ec900e8a618339a79 (patch) | |
| tree | cd160368f33fe680a1bb3751535645e2091d2d12 /internal/pkg | |
| parent | 0df87ab1117bf4da5163ad486a82628f1bada7ed (diff) | |
internal/pkg: fail on empty output directory
This works around the fact that execArtifact always creates the work directory when setting up the bind mount.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg')
| -rw-r--r-- | internal/pkg/exec.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/internal/pkg/exec.go b/internal/pkg/exec.go index 8b12694f..289b7f97 100644 --- a/internal/pkg/exec.go +++ b/internal/pkg/exec.go @@ -7,6 +7,7 @@ import ( "os" "runtime" "slices" + "syscall" "hakurei.app/container" "hakurei.app/container/check" @@ -286,8 +287,9 @@ func (a *execArtifact) cure(c *CureContext, hostNet bool) (err error) { } z.Bind(b[0], b[1], 0) } + work := c.GetWorkDir() z.Bind( - c.GetWorkDir(), + work, fhs.AbsRoot.Append("work"), std.BindWritable|std.BindEnsure, ) @@ -322,5 +324,19 @@ func (a *execArtifact) cure(c *CureContext, hostNet bool) (err error) { if err = z.Serve(); err != nil { return } - return z.Wait() + if err = z.Wait(); err != nil { + return + } + + // do not allow empty directories to succeed + for { + err = syscall.Rmdir(work.String()) + if err != syscall.EINTR { + break + } + } + if err != nil && errors.Is(err, syscall.ENOTEMPTY) { + err = nil + } + return } |
