fix: protect editor saves and clear failed restored tab state

This commit is contained in:
2026-11-05 21:38:35 +08:00
parent a3bef33988
commit 0e072eed3b
7 changed files with 192 additions and 22 deletions
+3 -6
View File
@@ -76,12 +76,9 @@ def test_failed_atomic_save_keeps_original_and_history(tmp_path, monkeypatch):
from mdhelper import file_versions
path = tmp_path / "note.md"; path.write_bytes(b"original\r\n")
store = VersionStore(tmp_path / "history")
replace = file_versions.os.replace
def failure(source, destination):
if Path(destination) == path:
raise OSError("simulated sharing violation")
replace(source, destination)
monkeypatch.setattr(file_versions.os, "replace", failure)
def failure(source, destination, backup):
raise OSError("simulated sharing violation")
monkeypatch.setattr(file_versions, "_replace_with_backup", failure)
with pytest.raises(OSError):
store.save(path, "changed")
assert path.read_bytes() == b"original\r\n"