before the great git rework

This commit is contained in:
2026-10-30 11:27:44 +01:00
parent 9bdda896af
commit b9c03a7637
45 changed files with 70 additions and 562 deletions
@@ -1,33 +0,0 @@
import Foundation
import HelderCore
import HelderServices
/// The project note in memory; records every write.
final class FakeNotes: NotesServicing, @unchecked Sendable {
private let state: Locked<(stored: String, writes: [String], failWrites: Bool)>
init(_ stored: String = "") {
state = Locked((stored, [], false))
}
var writes: [String] { state.current.writes }
var onDisk: String { state.current.stored }
var failWrites: Bool {
get { state.current.failWrites }
set { state.mutate { $0.failWrites = newValue } }
}
/// Another program rewrote the note file.
func setOnDisk(_ text: String) { state.mutate { $0.stored = text } }
func read() async -> String { state.current.stored }
func write(_ text: String) async throws {
try state.mutate { state in
if state.failWrites { throw CocoaError(.fileWriteNoPermission) }
state.writes.append(text)
state.stored = text
}
}
}