From 89dad4a3ceff76be2137083a530bcd57f9b1d00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Menou?= Date: Mon, 20 Jan 2025 14:04:50 +0100 Subject: [PATCH] Close files on error --- apps/transport/lib/registry/gtfs.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/transport/lib/registry/gtfs.ex b/apps/transport/lib/registry/gtfs.ex index 302aa61ef4..57351e8ce6 100644 --- a/apps/transport/lib/registry/gtfs.ex +++ b/apps/transport/lib/registry/gtfs.ex @@ -74,8 +74,10 @@ defmodule Transport.Registry.GTFS do {:ok, unzip} -> if has_stops?(unzip) do content = unzip |> Unzip.file_stream!("stops.txt") + # The zip_file is kept open for now as it's consumed later. Result.ok({content, zip_file}) else + Unzip.LocalFile.close(zip_file) Result.error("Missing stops.txt in #{archive}") end