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:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user