mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-12-04 02:48:22 +00:00
Fix more warnings from static code analysis
This commit is contained in:
parent
945b57d8fb
commit
5096f27bbd
@ -592,6 +592,7 @@ rsync.prepare = function
|
||||
|
||||
crsync._computed = { true }
|
||||
|
||||
--- @type any
|
||||
local computed = crsync._computed
|
||||
|
||||
local computedN = 2
|
||||
|
@ -13,6 +13,7 @@ then
|
||||
error( 'default already loaded' )
|
||||
end
|
||||
|
||||
--- @diagnostic disable-next-line: lowercase-global
|
||||
default = { }
|
||||
|
||||
|
||||
|
@ -15,12 +15,12 @@ settings {
|
||||
-- for testing purposes. prefix can be used to slow commands down.
|
||||
-- prefix = "sleep 5 && "
|
||||
--
|
||||
prefix = ""
|
||||
local prefix = ""
|
||||
|
||||
-----
|
||||
-- for testing purposes. uses bash command to hold local dirs in sync.
|
||||
--
|
||||
bash = {
|
||||
local bash = {
|
||||
delay = 0,
|
||||
|
||||
maxProcesses = 1,
|
||||
|
@ -7,7 +7,7 @@
|
||||
-----
|
||||
-- for testing purposes. just echos what is happening.
|
||||
--
|
||||
echo = {
|
||||
local echo = {
|
||||
maxProcesses = 1,
|
||||
delay = 1,
|
||||
onStartup = "/bin/echo telling about ^source",
|
||||
|
@ -22,12 +22,12 @@
|
||||
----
|
||||
-- forces this group.
|
||||
--
|
||||
fgroup = "staff"
|
||||
local fgroup = "staff"
|
||||
|
||||
-----
|
||||
-- script for all changes.
|
||||
--
|
||||
command =
|
||||
local command =
|
||||
-- checks if the group is the one enforced and sets them if not
|
||||
[[
|
||||
perm=`stat -c %A ^sourcePathname`
|
||||
@ -59,13 +59,13 @@ fi
|
||||
-- the carret as first char tells Lsycnd to call a shell altough it
|
||||
-- starts with a slash otherwisw
|
||||
--
|
||||
startup =
|
||||
local startup =
|
||||
[[^/bin/chgrp -R ]]..fgroup..[[ ^source || /bin/true &&
|
||||
/bin/chmod -R g+rw ^source || /bin/true &&
|
||||
/usr/bin/find ^source -type d | xargs chmod g+x
|
||||
]]
|
||||
|
||||
gforce = {
|
||||
local gforce = {
|
||||
maxProcesses = 99,
|
||||
delay = 1,
|
||||
onStartup = startup,
|
||||
|
@ -12,7 +12,7 @@
|
||||
--
|
||||
local formats = { jpg=true, gif=true, png=true, }
|
||||
|
||||
convert = {
|
||||
local convert = {
|
||||
delay = 0,
|
||||
|
||||
maxProcesses = 99,
|
||||
|
@ -19,7 +19,7 @@
|
||||
--
|
||||
-- Author: Daniel Miranda <danielkza2@gmail.com>
|
||||
--
|
||||
s3 = {}
|
||||
local s3 = {}
|
||||
|
||||
s3.checkgauge = {
|
||||
onCreate = false,
|
||||
|
@ -21,15 +21,16 @@ require("socket")
|
||||
|
||||
-- For demo reasons, do not detach
|
||||
settings.nodaemon = true
|
||||
hostname = "irc.freenode.org"
|
||||
local hostname = "irc.freenode.org"
|
||||
--hostname = "127.0.0.1"
|
||||
port = 6667
|
||||
nick = "lbot01"
|
||||
chan = "##lfile01"
|
||||
local port = 6667
|
||||
local nick = "lbot01"
|
||||
local chan = "##lfile01"
|
||||
|
||||
-- this blocks until the connection is established
|
||||
-- for once lets say this ok since Lsyncd didnt yet actually
|
||||
-- start.
|
||||
--- @diagnostic disable-next-line: undefined-global
|
||||
local ircSocket, err = socket.connect(hostname, port)
|
||||
if not ircSocket then
|
||||
log("Error", "Cannot connect to IRC: ", err)
|
||||
|
@ -12,7 +12,7 @@ cwriteln( '****************************************************************' )
|
||||
local tdir, srcdir, trgdir = mktemps( )
|
||||
|
||||
-- makes some startup data
|
||||
churn( srcdir, 10, init )
|
||||
churn( srcdir, 10, false )
|
||||
|
||||
local logs = { }
|
||||
--local logs = {'-log', 'Exec', '-log', 'Delay' }
|
||||
@ -34,10 +34,10 @@ posix.sleep( 10 )
|
||||
cwriteln( 'killing the Lsyncd daemon' )
|
||||
posix.kill( pid )
|
||||
|
||||
local _, exitmsg, lexitcode = posix.wait( lpid )
|
||||
local _, exitmsg, lexitcode = posix.wait( pid )
|
||||
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
||||
|
||||
result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
||||
local result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
||||
|
||||
if result == 'exit'
|
||||
then
|
||||
|
@ -36,10 +36,10 @@ posix.sleep( 10 )
|
||||
cwriteln( 'killing the Lsyncd daemon' )
|
||||
|
||||
posix.kill( pid )
|
||||
local _, exitmsg, lexitcode = posix.wait( lpid )
|
||||
local _, exitmsg, lexitcode = posix.wait( pid )
|
||||
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
||||
|
||||
result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
||||
local result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
||||
|
||||
if result == 'exit'
|
||||
then
|
||||
|
@ -43,11 +43,11 @@ cwriteln( 'killing the Lsyncd daemon' )
|
||||
|
||||
posix.kill(pid)
|
||||
|
||||
local _, exitmsg, lexitcode = posix.wait( lpid )
|
||||
local _, exitmsg, lexitcode = posix.wait( pid )
|
||||
|
||||
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
||||
|
||||
result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
||||
local result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
||||
|
||||
if result == 'exit'
|
||||
then
|
||||
|
@ -132,7 +132,7 @@ cwriteln( 'waiting for Lsyncd to remove destination' )
|
||||
|
||||
posix.sleep( 20 )
|
||||
|
||||
result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
||||
local result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
||||
|
||||
if result ~= 'exit' or code ~= 0
|
||||
then
|
||||
@ -155,7 +155,7 @@ testfiles( )
|
||||
cwriteln( 'killing started Lsyncd' )
|
||||
|
||||
posix.kill( pid )
|
||||
local _, exitmsg, exitcode = posix.wait( lpid )
|
||||
local _, exitmsg, exitcode = posix.wait( pid )
|
||||
|
||||
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', exitcode );
|
||||
|
||||
|
@ -115,7 +115,7 @@ cwriteln( 'waiting for Lsyncd to remove destination' )
|
||||
|
||||
posix.sleep( 5 )
|
||||
|
||||
result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
||||
local result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
||||
|
||||
if result ~= 'exit' or code ~= 0
|
||||
then
|
||||
@ -137,7 +137,7 @@ testfiles( )
|
||||
cwriteln( 'killing started Lsyncd' )
|
||||
|
||||
posix.kill( pid )
|
||||
local _, exitmsg, exitcode = posix.wait( lpid )
|
||||
local _, exitmsg, exitcode = posix.wait( pid )
|
||||
|
||||
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', exitcode );
|
||||
|
||||
|
@ -113,7 +113,7 @@ os.execute( 'rm -rf ' .. srcdir .. '/*' )
|
||||
cwriteln( 'waiting for Lsyncd to remove destination' )
|
||||
posix.sleep( 5 )
|
||||
|
||||
result, code = execute( 'diff -urN '..srcdir..' '..trgdir )
|
||||
local result, code = execute( 'diff -urN '..srcdir..' '..trgdir )
|
||||
|
||||
if result ~= 'exit' or code ~= 0
|
||||
then
|
||||
@ -129,7 +129,7 @@ testfiles( )
|
||||
|
||||
cwriteln( 'killing started Lsyncd' )
|
||||
posix.kill( pid )
|
||||
local _, exitmsg, lexitcode = posix.wait( lpid )
|
||||
local _, exitmsg, lexitcode = posix.wait( pid )
|
||||
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
||||
posix.sleep( 1 )
|
||||
|
||||
|
@ -109,7 +109,7 @@ cwriteln( 'waiting for Lsyncd to remove destination' )
|
||||
|
||||
posix.sleep( 5 )
|
||||
|
||||
result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
||||
local result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
||||
|
||||
if result ~= 'exit' or code ~= 0
|
||||
then
|
||||
@ -131,7 +131,7 @@ testfiles( )
|
||||
cwriteln( 'killing started Lsyncd' )
|
||||
|
||||
posix.kill( pid )
|
||||
local _, exitmsg, exitcode = posix.wait( lpid )
|
||||
local _, exitmsg, exitcode = posix.wait( pid )
|
||||
|
||||
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', exitcode );
|
||||
|
||||
|
@ -19,7 +19,7 @@ then
|
||||
end
|
||||
cwriteln( 'starting Lsyncd' )
|
||||
|
||||
logs = { }
|
||||
local logs = { }
|
||||
local pid =
|
||||
spawn(
|
||||
'./lsyncd',
|
||||
@ -55,12 +55,12 @@ posix.sleep( 10 )
|
||||
cwriteln( '* killing Lsyncd' )
|
||||
|
||||
posix.kill( pid )
|
||||
local _, exitmsg, lexitcode = posix.wait(lpid)
|
||||
local _, exitmsg, lexitcode = posix.wait(pid)
|
||||
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode)
|
||||
posix.sleep( 1 )
|
||||
|
||||
cwriteln( '* differences:' )
|
||||
result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
||||
local result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
||||
|
||||
if result == 'exit'
|
||||
then
|
||||
|
@ -69,7 +69,7 @@ testfile( srcdir..'b' )
|
||||
testfile( srcdir..'c' )
|
||||
cwriteln( 'killing started Lsyncd' )
|
||||
posix.kill( pid )
|
||||
local _, exitmsg, lexitcode = posix.wait( lpid )
|
||||
local _, exitmsg, lexitcode = posix.wait( pid )
|
||||
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode)
|
||||
posix.sleep(1);
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
--- @diagnostic disable: lowercase-global, need-check-nil
|
||||
|
||||
-- common testing environment
|
||||
posix = require( 'posix' )
|
||||
string = require( 'string' )
|
||||
@ -11,6 +13,7 @@ local c0='\027[0m'
|
||||
|
||||
-- compatibility with 5.1
|
||||
if table.unpack == nil then
|
||||
--- @diagnostic disable-next-line: deprecated
|
||||
table.unpack = unpack
|
||||
end
|
||||
|
||||
@ -46,8 +49,7 @@ end
|
||||
-- If environment variable 'SEED' is set,
|
||||
-- that one is used seed.
|
||||
--
|
||||
local seed = os.getenv( 'SEED') or os.time( )
|
||||
|
||||
local seed = tonumber(os.getenv( 'SEED')) or os.time( )
|
||||
math.randomseed( seed )
|
||||
|
||||
cwriteln( 'random seed: ', seed )
|
||||
@ -61,6 +63,10 @@ function mktempd
|
||||
( )
|
||||
local f = io.popen( 'mktemp -td ltest.XXX', 'r' )
|
||||
|
||||
if f == nil then
|
||||
return error("can't create testing directory")
|
||||
end
|
||||
|
||||
local s = f:read( '*a' )
|
||||
|
||||
f:close( )
|
||||
|
Loading…
Reference in New Issue
Block a user