fix: implemented TD-04, embedding indexes flush to disk on shutdown

This commit is contained in:
2026-06-11 21:34:26 +02:00
parent 63e35d19e3
commit d8b24c9b72
3 changed files with 57 additions and 2 deletions

View File

@@ -89,8 +89,17 @@ defmodule BDS.Desktop.Shutdown do
:ok
end
# quit/0 SIGKILLs the BEAM, so no terminate/2 callback ever runs on shutdown;
# everything that must reach disk has to be flushed here. Each step is
# hardened individually so one failure never blocks quit or the other steps.
defp persist_safely do
MainWindow.persist_now()
persist_step(fn -> MainWindow.persist_now() end)
persist_step(fn -> BDS.Embeddings.Index.flush_all() end)
:ok
end
defp persist_step(fun) do
fun.()
:ok
rescue
_error -> :ok