Mercurial Hosting > luan
changeset 2120:2deeafc76ff0 ssltesting tip
delete_junk
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Tue, 06 Jan 2026 20:49:33 -0700 |
| parents | 57381da15e68 |
| children | |
| files | src/luan/host/Https.luan |
| diffstat | 1 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/host/Https.luan Tue Jan 06 15:10:58 2026 -0800 +++ b/src/luan/host/Https.luan Tue Jan 06 20:49:33 2026 -0700 @@ -3,6 +3,7 @@ local new_error = Luan.new_error or error() local load_file = Luan.load_file or error() local pairs = Luan.pairs or error() +local ipairs = Luan.ipairs or error() local Io = require "luan:Io.luan" local ip = Io.ip or error() local uri = Io.uri or error() @@ -41,6 +42,32 @@ -- for testing Https.get_files = get_files +local function do_delete_junk(file,canonicals) + if canonicals[file.canonical().to_string()] == nil then + sys_logger.info("delete "..file.to_string()) + file.delete() + elseif file.is_directory() then + for _, child in ipairs(file.children()) do + do_delete_junk(child,canonicals) + end + end +end + +local function delete_junk(domain,site_dir) + local files = get_files(domain,site_dir) + files.info_luan = site_dir.child("info.luan") + local canonicals = {} + for _, file in pairs(files) do + canonicals[file.canonical().to_string()] = true + end + for _, child in ipairs(site_dir.children()) do + if child.name() == "site" then + continue + end + do_delete_junk(child,canonicals) + end +end + local function nginx_ssl_conf(domain,files,luanhost_dir) %> server { @@ -149,6 +176,7 @@ local nginx = ` nginx_ssl_conf(domain,files,luanhost_dir) ` files.nginx_file.write(nginx) end + delete_junk(domain,site_dir) end local function do_set_https(is_https,domain,site_dir,luanhost_dir,dry_run)
