From 5c6151a66212c9770ab052f6dce5032a00e01695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?= Date: Thu, 12 Dec 2024 18:09:11 +0100 Subject: [PATCH] Add verifications of the registry cache ets table --- lib/hex/registry/server.ex | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/hex/registry/server.ex b/lib/hex/registry/server.ex index 55a9129f..7b01861b 100644 --- a/lib/hex/registry/server.ex +++ b/lib/hex/registry/server.ex @@ -235,7 +235,7 @@ defmodule Hex.Registry.Server do end defp open_ets(path) do - case :ets.file2tab(path) do + case :ets.file2tab(path, verify: true) do {:ok, tid} -> tid @@ -268,7 +268,12 @@ defmodule Hex.Registry.Server do defp persist(tid, path) do dir = Path.dirname(path) File.mkdir_p!(dir) - :ok = :ets.tab2file(tid, String.to_charlist(path)) + + :ok = + :ets.tab2file(tid, String.to_charlist(path), + extended_info: [:object_count, :md5sum], + sync: true + ) end defp purge_repo_from_cache(packages, %{ets: ets}) do