From b495761db4e93a9ec37bfa49df35d3085ef69c5c Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Fri, 22 Nov 2024 11:27:08 -0600 Subject: [PATCH] fix up acme challenge turd cleanup --- workers/lets_encrypt_worker.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/workers/lets_encrypt_worker.rb b/workers/lets_encrypt_worker.rb index e558a7e6..76db737c 100644 --- a/workers/lets_encrypt_worker.rb +++ b/workers/lets_encrypt_worker.rb @@ -190,11 +190,19 @@ class LetsEncryptWorker wellknown_path = File.join site.base_files_path, '.well-known' acme_challenge_path = File.join wellknown_path, 'acme-challenge' - if File.exist?(acme_challenge_path) - FileUtils.rm acme_challenge_path - site.site_files_dataset.where(path: '.well-known/acme-challenge').destroy + site.site_files_dataset.where(Sequel.like(:path, '.well-known/acme-challenge%')).each do |s| + s.destroy end + Dir.glob(File.join(acme_challenge_path, '*')).each do |f| + FileUtils.rm f + end + + if Dir.exist?(acme_challenge_path) + Dir.rmdir acme_challenge_path + end + + # .well-known was not created by user, removing to prevent confusion if site.site_files_dataset.where(path: '.well-known').count == 0 begin Dir.rmdir wellknown_path