feat: implement atomic writes for filesystem backend

- Add WriteFile method to mock filesystem (non-atomic path, creates files)
- Implement WriteFileAtomic in mock with temp file + rename pattern
  using .tmp/ directory, matching real filesystem semantics
- Update WriteFileTask.Execute() to use WriteFileAtomic
- Update FlushAll() to use WriteFileAtomic
- Fix mock to create files on write (matching os.WriteFile behavior)
- Update tests to match new semantics (create-if-not-exists)
This commit is contained in:
gmp
2026-06-04 18:01:51 -04:00
parent d73cb0be2c
commit 93a5f879f5
16 changed files with 334 additions and 38 deletions
+4 -4
View File
@@ -45,7 +45,7 @@ type Container struct {
region Region
visible bool
background Color
children []Element
Children []Element // Changed to Exported
}
func (c Container) Type() string { return "container" }
@@ -61,8 +61,8 @@ func (c Container) Draw(gtx layout.Context, r *Renderer) {
// String returns a string representation of the Container and all children.
func (c Container) String() string {
var sb strings.Builder
sb.WriteString(fmt.Sprintf("Container[%s] region=%+v bg=%#v children=%d", c.id, c.region, c.background, len(c.children)))
for i, child := range c.children {
sb.WriteString(fmt.Sprintf("Container[%s] region=%+v bg=%#v children=%d", c.id, c.region, c.background, len(c.Children)))
for i, child := range c.Children {
if str, ok := any(child).(fmt.Stringer); ok {
sb.WriteString(fmt.Sprintf("\n [%d] %s", i, str.String()))
} else {
@@ -78,7 +78,7 @@ func NewContainer(region Region, bg Color, children []Element) Container {
region: region,
visible: true,
background: bg,
children: children,
Children: children,
}
}
+1 -1
View File
@@ -257,7 +257,7 @@ func (r *Renderer) drawElement(gtx layout.Context, e Element) {
}.Push(gtx.Ops)
e.Draw(gtx, r) // draw container background
offset := op.Offset(image.Pt(int(r.toPx(reg.X)), int(r.toPx(reg.Y)))).Push(gtx.Ops)
for _, child := range container.children {
for _, child := range container.Children {
r.drawElement(gtx, child)
}
offset.Pop()