Mercurial Hosting > luan
changeset 1858:5257f78d8c83 default tip
push is_executable
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 15 Mar 2025 14:35:48 -0600 |
parents | 0c0b0acf780d |
children | |
files | src/luan/host/main.luan src/luan/modules/Boot.luan src/luan/modules/IoLuan.java src/luan/modules/host/Hosting.luan |
diffstat | 4 files changed, 18 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/host/main.luan Wed Mar 05 21:41:22 2025 -0700 +++ b/src/luan/host/main.luan Sat Mar 15 14:35:48 2025 -0600 @@ -115,12 +115,13 @@ starts_with( file.to_string(), site_dir.to_string() ) or error "security violation" end -function fns.copy_file(domain,password,dir,name,content) +function fns.copy_file(domain,password,dir,name,content,is_executable) local site_dir = get_dir(domain,password) site_dir or error "domain not found" local file = Io.schemes.file(dir).child(name) security(site_dir,file) file.write(content) + file.set_executable(is_executable) end function fns.mkdir(domain,password,dir,name)
--- a/src/luan/modules/Boot.luan Wed Mar 05 21:41:22 2025 -0700 +++ b/src/luan/modules/Boot.luan Sat Mar 15 14:35:48 2025 -0600 @@ -207,6 +207,8 @@ this.link_from = io.link_from this.symlink_from = io.symlink_from this.is_symbolic_link = io.is_symbolic_link + this.can_execute = io.file.canExecute + this.set_executable = io.set_executable function this.child(name) return new_LuanFile( io.child(name) )
--- a/src/luan/modules/IoLuan.java Wed Mar 05 21:41:22 2025 -0700 +++ b/src/luan/modules/IoLuan.java Sat Mar 15 14:35:48 2025 -0600 @@ -444,6 +444,13 @@ return file.exists(); } + @Override public long checksum() throws IOException, LuanException { + long rtn = super.checksum(); + if( file.canExecute() ) + rtn *= 31; + return rtn; + } + public void move_to(Luan luan,Object destObj) throws LuanException, IOException { File dest = objToFile(luan,destObj); if( dest==null ) @@ -497,6 +504,11 @@ public boolean is_symbolic_link() { return IoUtils.isSymbolicLink(file); } + + public void set_executable(boolean executable) throws LuanException { + if( !file.setExecutable(executable) ) + throw new LuanException("couldn't set_executable on "+file); + } } public static LuanUrl classpath(Luan luan,String name) throws LuanException {
--- a/src/luan/modules/host/Hosting.luan Wed Mar 05 21:41:22 2025 -0700 +++ b/src/luan/modules/host/Hosting.luan Sat Mar 15 14:35:48 2025 -0600 @@ -36,7 +36,7 @@ if here.is_file() then if there == nil or there.checksum ~= here.checksum() then print("copying "..here.to_string()) - host.copy_file(domain,password,there_parent.path,here.name(),here.read_binary()) + host.copy_file(domain,password,there_parent.path,here.name(),here.read_binary(),here.can_execute()) end elseif here.is_directory() then if here.name() == "local" then @@ -88,7 +88,7 @@ there = there.children[s] or error("'"..s.."' not found on remote") end print("copying "..my_file.to_string()) - host.copy_file(domain,password,there.path,my_file.name(),my_file.read_binary()) + host.copy_file(domain,password,there.path,my_file.name(),my_file.read_binary(),my_file.can_execute()) host.update_handler(domain,password) host.close() end