From a2d65d4b5ed701fcda8bc32d27e5aca30bde85a1 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Mon, 8 Jul 2024 15:18:06 -0300 Subject: [PATCH] Cleanup tmp directory after build --- TODO.md | 2 +- src/commands/build.cr | 3 ++- src/daemon/funko.cr | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/TODO.md b/TODO.md index b2ae90c..022a66f 100644 --- a/TODO.md +++ b/TODO.md @@ -32,7 +32,7 @@ * Implement `faaso help command` * ✅ Fix `export examples/hello_crystal` it has a `template/` * ✅ Implement zero-downtime rollout (`faaso deploy`) -* Cleanup `tmp/` after use unless `DEBUG` is set +* ✅ Cleanup `tmp/whatever` after use * `faaso scale` remote is broken # Things to do but not before release diff --git a/src/commands/build.cr b/src/commands/build.cr index 5530f05..7eb388d 100644 --- a/src/commands/build.cr +++ b/src/commands/build.cr @@ -16,6 +16,7 @@ module Faaso if options["--local"] Log.info { "Building function... #{funko.name} in #{tmp_dir}" } funko.build tmp_dir + FileUtils.rm_rf(tmp_dir) next end Faaso.check_version @@ -39,7 +40,7 @@ module Faaso end end end - + FileUtils.rm_rf(tmp_dir) tmp = File.tempname File.open(tmp, "w") do |outf| outf << buf diff --git a/src/daemon/funko.cr b/src/daemon/funko.cr index 8c3bde4..fff6787 100644 --- a/src/daemon/funko.cr +++ b/src/daemon/funko.cr @@ -53,8 +53,9 @@ module Funko # Build the thing run_faaso(["build", tmp_dir.to_s, "--no-runtime"], env) + ensure + FileUtils.rm_rf(tmp_dir) unless tmp_dir.nil? end - # Endpoints for the web frontend # General status for the front page