Integrate real filesystem with interface abstraction
- Define pool.FileSystem interface in internal/io/pool/filesystem.go - Move DirEntry interface to internal/io/pool/types/types.go to break the pool <-> mock import cycle - Implement real.FileSystem with atomic writes (temp file + os.Rename) - Update mock.FileSystem to satisfy pool.FileSystem interface - Update worker pool tasks to accept pool.FileSystem interface - Update main.go to use RealFileSystem by default, with -root flag - Update all browser/editor/test references to types.DirEntry
This commit is contained in:
@@ -224,6 +224,24 @@ Key design points:
|
||||
- [ ] Undo/Redo stack implementation. — **NOT STARTED** (`UndoStack` field is commented out in `EditorState`)
|
||||
- [ ] Performance testing with large files (>1MB). — **NOT STARTED**
|
||||
|
||||
### 4.5 Real Filesystem Integration
|
||||
|
||||
To support real filesystem operations with minimal changes, we are abstracting the filesystem behind an interface.
|
||||
|
||||
### 4.5.1 Design
|
||||
- **Interface Definition**: Define a `FileSystem` interface in `internal/io/pool/` that captures the required operations (`ReadDir`, `ReadFile`, `WriteFile`, `DirExists`, etc.).
|
||||
- **Mock Update**: Update the existing `internal/io/pool/mock` to satisfy this interface.
|
||||
- **Real Implementation**: Create `internal/io/pool/real` that implements the `FileSystem` interface using standard `os` and `path/filepath` packages.
|
||||
- **Dependency Injection**: Update worker pool tasks to accept the `FileSystem` interface instead of the concrete `*mock.FileSystem` type.
|
||||
- **Atomic Writes**: The `RealFileSystem` must also implement atomic writes via temporary files and `os.Rename` to maintain the consistency guarantees of the mock.
|
||||
|
||||
### 4.5.2 Implementation Roadmap
|
||||
1. Define `pool.FileSystem` interface.
|
||||
2. Update `mock.FileSystem` to satisfy the interface.
|
||||
3. Update `pool` tasks to accept the interface.
|
||||
4. Implement `real.FileSystem`.
|
||||
5. Update `main.go` to inject the correct implementation based on build/runtime flags.
|
||||
|
||||
---
|
||||
|
||||
## 5. Interaction Flow (Example: Keyboard/Mouse Input)
|
||||
|
||||
Reference in New Issue
Block a user