From e9fe9b90ba5c9492e208d82867fe589f2c9464ea Mon Sep 17 00:00:00 2001 From: "Violet V." Date: Sun, 20 Oct 2024 11:56:18 -0400 Subject: [PATCH] Make ACME challenge cleanup more specific The .well-known directory has uses other than ACME challenge response, so deleting the whole thing as cleanup is incorrect. I ran into an issue where files I uploaded inside that directory (which worked initially) disappeared after a while, I assume around the time neocities renewed the certs for my custom domain. The file (and the .well-known dir) still appeared in GETs on the /api/list endpoint, but requests for them on my site returned 404. I tried to re-upload the original to the same path but it appears since it had the same content some optimization was preventing it from restoring the deleted file, because it continued to 404. Uploading the same file to a different path inside .well-known worked, and then uploading a file with different content to the original path worked. This commit changes the ACME cleanup code to only remove the .well-known/acme-challenge directory that it uses, and leaves any other files alone. --- workers/lets_encrypt_worker.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workers/lets_encrypt_worker.rb b/workers/lets_encrypt_worker.rb index d151889d..493100d6 100644 --- a/workers/lets_encrypt_worker.rb +++ b/workers/lets_encrypt_worker.rb @@ -187,7 +187,7 @@ class LetsEncryptWorker end def clean_wellknown_turds(site) - wellknown_path = File.join(site.base_files_path, '.well-known') + wellknown_path = File.join(site.base_files_path, '.well-known', 'acme-challenge') if File.exist?(wellknown_path) FileUtils.rm_rf wellknown_path