mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-06-13 21:52:25 +00:00
This commit is contained in:
parent
d823e8b580
commit
10fe22500e
3
lsyncd.c
3
lsyncd.c
|
@ -1074,7 +1074,8 @@ masterloop(lua_State *L)
|
||||||
/* this is not a real loop, it will only be runned once max.
|
/* this is not a real loop, it will only be runned once max.
|
||||||
* this is just using break as comfortable jump down. */
|
* this is just using break as comfortable jump down. */
|
||||||
while (settings.statusfile) {
|
while (settings.statusfile) {
|
||||||
int fd = open(settings.statusfile, O_WRONLY | O_CREAT | O_TRUNC);
|
int fd = open(settings.statusfile,
|
||||||
|
O_WRONLY | O_CREAT | O_TRUNC, 0664);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
printlogf(L, ERROR,
|
printlogf(L, ERROR,
|
||||||
"Cannot open statusfile '%s' for writing.",
|
"Cannot open statusfile '%s' for writing.",
|
||||||
|
|
24
lsyncd.lua
24
lsyncd.lua
|
@ -58,27 +58,27 @@ local meta_check_array = {
|
||||||
--
|
--
|
||||||
local meta_check_count_array = {
|
local meta_check_count_array = {
|
||||||
__index = function(t, k)
|
__index = function(t, k)
|
||||||
if k == size then
|
--TODO if k == size then
|
||||||
return rawget(t, "size")
|
-- return rawget(t, "size")
|
||||||
end
|
-- end
|
||||||
if type(k) ~= "number" then
|
if type(k) ~= "number" then
|
||||||
error("This table is an array and must have numeric keys", 2)
|
error("This table is an array and must have numeric keys", 2)
|
||||||
end
|
end
|
||||||
return rawget(t, "_t")[k]
|
return rawget(t, "mt")[k]
|
||||||
end,
|
end,
|
||||||
|
|
||||||
__newindex = function(t, k, v)
|
__newindex = function(t, k, v)
|
||||||
if type(k) ~= "number" then
|
if type(k) ~= "number" then
|
||||||
error("This table is an array and must have numeric keys", 2)
|
error("This table is an array and must have numeric keys", 2)
|
||||||
end
|
end
|
||||||
local _t = rawget(t, "_t")
|
local mt = rawget(t, "mt")
|
||||||
local vb = _t[k]
|
local vb = mt[k]
|
||||||
if v and not vb then
|
if v and not vb then
|
||||||
rawset(t, "size", rawget(t, "size") + 1)
|
rawset(t, "size", rawget(t, "size") + 1)
|
||||||
elseif not v and vb then
|
elseif not v and vb then
|
||||||
rawset(t, "size", rawget(t, "size") - 1)
|
rawset(t, "size", rawget(t, "size") - 1)
|
||||||
end
|
end
|
||||||
_t[k] = v
|
mt[k] = v
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ end
|
||||||
-- which counts the number of entries
|
-- which counts the number of entries
|
||||||
--
|
--
|
||||||
local function new_count_array()
|
local function new_count_array()
|
||||||
local t = { size = 0, _t = {} }
|
local t = { size = 0, mt = {} }
|
||||||
setmetatable(t, meta_check_count_array)
|
setmetatable(t, meta_check_count_array)
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
@ -456,13 +456,15 @@ function lsyncd_status_report(fd)
|
||||||
local w = lsyncd.writefd
|
local w = lsyncd.writefd
|
||||||
w(fd, "Lsyncd status report at "..os.date().."\n\n")
|
w(fd, "Lsyncd status report at "..os.date().."\n\n")
|
||||||
w(fd, "Watching "..watches.size.." directories\n")
|
w(fd, "Watching "..watches.size.." directories\n")
|
||||||
for i, v in pairs(watches) do
|
for i, v in pairs(watches.mt) do
|
||||||
w(fd, " "..i..": ")
|
w(fd, " "..i..": ")
|
||||||
if i ~= v.wd then
|
if i ~= v.wd then
|
||||||
w(fd, "[Error: wd/v.wd "..i.."~="..v.wd.."]")
|
w(fd, "[Error: wd/v.wd "..i.."~="..v.wd.."]")
|
||||||
end
|
end
|
||||||
for _, s in pairs(v.syncs) do
|
for _, s in ipairs(v.syncs) do
|
||||||
w(fd, "("..s.origin.source.."//"..s.origin.path..")")
|
local o = s.origin
|
||||||
|
w(fd, "("..o.source.."|"..(o.path or "")..
|
||||||
|
"|"..(o.filename or "")..")")
|
||||||
end
|
end
|
||||||
w(fd, "\n")
|
w(fd, "\n")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user