Fix ox-hugo export with internal ID links and Quartz config

- Add org-id resolution for [[id:...]] links by building ID locations
  database once before parallel export
- Handle broken file links gracefully with org-export-with-broken-links
- Fix race condition in parallel exports by pre-building ID cache
- Fix Quartz config not being applied: cp was preserving nix store hash
  prefix in filename instead of using explicit destination filename
- Continue pipeline even when some exports fail, reporting failures
- Improve error handling and logging throughout export pipeline
This commit is contained in:
Ignacio Ballesteros
2026-02-22 19:55:17 +01:00
parent c7bd37bb95
commit 1fac31dc73
9 changed files with 169 additions and 80 deletions

View File

@@ -87,18 +87,14 @@ defmodule OrgGarden.Server do
}
# Run initial pipeline synchronously
case run_initial_pipeline(state) do
:ok ->
# Start supervised components
case start_supervisor(state) do
{:ok, sup_pid} ->
Logger.info("Server started on http://localhost:#{http_port}")
Logger.info("Watching #{notes_dir} for changes")
{:ok, %{state | supervisor_pid: sup_pid}}
:ok = run_initial_pipeline(state)
{:error, reason} ->
{:stop, reason}
end
# Start supervised components
case start_supervisor(state) do
{:ok, sup_pid} ->
Logger.info("Server started on http://localhost:#{http_port}")
Logger.info("Watching #{notes_dir} for changes")
{:ok, %{state | supervisor_pid: sup_pid}}
{:error, reason} ->
{:stop, reason}
@@ -148,13 +144,13 @@ defmodule OrgGarden.Server do
# Export all org files
case OrgGarden.Export.export_all(notes_dir, output_dir) do
{:ok, 0} ->
{:ok, 0, []} ->
Logger.warning("No .org files found in #{notes_dir}")
# Still generate index (will be empty or have default content)
OrgGarden.Index.generate(content_dir)
:ok
{:ok, count} ->
{:ok, count, []} ->
Logger.info("Exported #{count} file(s)")
# Run transforms
@@ -168,9 +164,23 @@ defmodule OrgGarden.Server do
OrgGarden.Index.generate(content_dir)
:ok
{:error, failures} ->
Logger.error("Failed to export #{length(failures)} file(s)")
{:error, {:export_failed, failures}}
{:ok, count, failures} ->
Logger.warning("Exported #{count} file(s), #{length(failures)} failed")
Enum.each(failures, fn {f, {:error, {:emacs_exit, code}}} ->
Logger.warning(" failed: #{Path.basename(f)} (emacs exit code #{code})")
end)
# Continue with transforms and index anyway
{:ok, stats} = OrgGarden.run(content_dir, @transforms, pipeline_opts)
Enum.each(stats, fn {mod, c} ->
Logger.info("#{inspect(mod)}: #{c} file(s) modified")
end)
# Generate index
OrgGarden.Index.generate(content_dir)
:ok
end
end