comparison src/luan/modules/host/Hosting.luan @ 1381:8d7a39ca2c0c

add Rpc in_backup_read_lock
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 28 Jul 2019 20:15:38 -0600
parents ae2321a09723
children 5b8f76e26ab7
comparison
equal deleted inserted replaced
1380:04482e2a6ca3 1381:8d7a39ca2c0c
8 local Io = require "luan:Io.luan" 8 local Io = require "luan:Io.luan"
9 local print = Io.print or error() 9 local print = Io.print or error()
10 local Rpc = require "luan:Rpc.luan" 10 local Rpc = require "luan:Rpc.luan"
11 local String = require "luan:String.luan" 11 local String = require "luan:String.luan"
12 local matches = String.matches or error() 12 local matches = String.matches or error()
13 local Logging = require "luan:logging/Logging.luan"
14 local logger = Logging.logger "Hosting"
13 15
14 16
15 local Hosting = {} 17 local Hosting = {}
16 18
17 19
19 local my_dir = Io.uri("file:"..dir) 21 local my_dir = Io.uri("file:"..dir)
20 my_dir.exists() or error("directory '"..dir.."' not found") 22 my_dir.exists() or error("directory '"..dir.."' not found")
21 my_dir.is_directory() or error("'"..dir.."' is not a directory") 23 my_dir.is_directory() or error("'"..dir.."' is not a directory")
22 local host = Rpc.remote(domain) 24 local host = Rpc.remote(domain)
23 local tree = host.get(domain,password) 25 local tree = host.get(domain,password)
26 host.in_backup_read_lock()
24 if tree == nil then 27 if tree == nil then
25 print("creating "..domain) 28 print("creating "..domain)
26 tree = host.create(domain,password) 29 tree = host.create(domain,password)
27 end 30 end
28 31
62 host.close() 65 host.close()
63 end 66 end
64 67
65 function Hosting.delete(domain,password) 68 function Hosting.delete(domain,password)
66 local host = Rpc.remote(domain) 69 local host = Rpc.remote(domain)
70 host.in_backup_read_lock()
67 host.delete(domain,password) 71 host.delete(domain,password)
68 host.close() 72 host.close()
69 end 73 end
70 74
71 function Hosting.exists(domain) 75 function Hosting.exists(domain)
75 return rtn 79 return rtn
76 end 80 end
77 81
78 function Hosting.change_domain(old_domain,new_domain,password) 82 function Hosting.change_domain(old_domain,new_domain,password)
79 local host = Rpc.remote(new_domain) 83 local host = Rpc.remote(new_domain)
84 host.in_backup_read_lock()
80 local rtn = host.change_domain(old_domain,new_domain,password) 85 local rtn = host.change_domain(old_domain,new_domain,password)
81 host.close() 86 host.close()
82 return rtn 87 return rtn
83 end 88 end
84 89
85 function Hosting.change_password(domain,old_password,new_password) 90 function Hosting.change_password(domain,old_password,new_password)
86 local host = Rpc.remote(domain) 91 local host = Rpc.remote(domain)
92 host.in_backup_read_lock()
87 local rtn = host.change_password(domain,old_password,new_password) 93 local rtn = host.change_password(domain,old_password,new_password)
88 host.close() 94 host.close()
89 return rtn 95 return rtn
90 end 96 end
91 97