From e0835dce6c7a9de4ef1a4379a4a87ef19a86e8f4 Mon Sep 17 00:00:00 2001 From: Gavin McDonald Date: Sun, 4 May 2025 14:49:26 -0400 Subject: [PATCH] hash label options to filename --- lib/labelmaker_web/live/label.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/labelmaker_web/live/label.ex b/lib/labelmaker_web/live/label.ex index 908db21..250187d 100644 --- a/lib/labelmaker_web/live/label.ex +++ b/lib/labelmaker_web/live/label.ex @@ -19,7 +19,13 @@ defmodule LabelmakerWeb.Label do |> Map.merge(params) |> Map.take(@permitted_keys) - filename = "#{options["label"]}.png" + filename = + options + |> inspect() + |> (fn str -> :crypto.hash(:sha256, str) end).() + |> Base.encode16(case: :lower) + + filename = filename <> ".png" filepath = Path.join(@label_dir, filename) unless File.exists?(filepath) do