Skip to content

Commit 10f0740

Browse files
[fix] Fix configuration files not getting removed #153
Closes #153
1 parent 27196a5 commit 10f0740

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

openwisp-config/files/sbin/openwisp-update-config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ if lfs.attributes(remote_config_dir, 'mode') == 'directory' then
148148
-- ensure we are acting on a file
149149
if lfs.attributes(remote_path, 'mode') == 'file' then
150150
-- if there's no backup of the file yet, create one
151-
if not utils.file_exists(stored_path) then
151+
if (not utils.file_exists(stored_path) and not utils.file_exists(remote_path)) then
152152
os.execute('cp '..standard_path..' '..stored_path)
153153
end
154154
-- MERGE mode

openwisp-config/tests/test_update_config.lua

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,11 @@ function TestUpdateConfig.test_update()
123123
luaunit.assertNotNil(restoreFile)
124124
luaunit.assertEquals(restoreFile:read('*all'), 'restore-me\n')
125125
luaunit.assertNil(io.open(openwisp_dir..'/stored/etc/restore-me'))
126-
-- ensure network configuration file is backed up
127-
local storedNetworkFile = io.open(stored_dir .. '/etc/config/network')
128-
luaunit.assertNotNil(storedNetworkFile)
129-
local initialNetworkFile = io.open('update/network')
130-
luaunit.assertEquals(storedNetworkFile:read('*all'), initialNetworkFile:read('*all'))
131-
-- ensure system configuration file is backed up
126+
-- ensure network and configuration file is not backed up as it is overwritten by remote
127+
local storedNetworkFile = io.open(openwisp_dir .. '/etc/config/network')
128+
luaunit.assertNil(storedNetworkFile)
132129
local storedSystemFile = io.open(stored_dir .. '/etc/config/system')
133-
luaunit.assertNotNil(storedSystemFile)
134-
local initialSystemFile = io.open('update/system')
135-
luaunit.assertEquals(storedSystemFile:read('*all'), initialSystemFile:read('*all'))
130+
luaunit.assertNil(storedSystemFile)
136131
end
137132

138133
function TestUpdateConfig.test_update_conf_arg()

0 commit comments

Comments
 (0)