Skip to content

Commit

Permalink
[fix] Fix configuration files not getting removed #153
Browse files Browse the repository at this point in the history
Closes #153
  • Loading branch information
devkapilbansal committed Nov 24, 2021
1 parent 27196a5 commit 10f0740
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion openwisp-config/files/sbin/openwisp-update-config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ if lfs.attributes(remote_config_dir, 'mode') == 'directory' then
-- ensure we are acting on a file
if lfs.attributes(remote_path, 'mode') == 'file' then
-- if there's no backup of the file yet, create one
if not utils.file_exists(stored_path) then
if (not utils.file_exists(stored_path) and not utils.file_exists(remote_path)) then
os.execute('cp '..standard_path..' '..stored_path)
end
-- MERGE mode
Expand Down
13 changes: 4 additions & 9 deletions openwisp-config/tests/test_update_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,11 @@ function TestUpdateConfig.test_update()
luaunit.assertNotNil(restoreFile)
luaunit.assertEquals(restoreFile:read('*all'), 'restore-me\n')
luaunit.assertNil(io.open(openwisp_dir..'/stored/etc/restore-me'))
-- ensure network configuration file is backed up
local storedNetworkFile = io.open(stored_dir .. '/etc/config/network')
luaunit.assertNotNil(storedNetworkFile)
local initialNetworkFile = io.open('update/network')
luaunit.assertEquals(storedNetworkFile:read('*all'), initialNetworkFile:read('*all'))
-- ensure system configuration file is backed up
-- ensure network and configuration file is not backed up as it is overwritten by remote
local storedNetworkFile = io.open(openwisp_dir .. '/etc/config/network')
luaunit.assertNil(storedNetworkFile)
local storedSystemFile = io.open(stored_dir .. '/etc/config/system')
luaunit.assertNotNil(storedSystemFile)
local initialSystemFile = io.open('update/system')
luaunit.assertEquals(storedSystemFile:read('*all'), initialSystemFile:read('*all'))
luaunit.assertNil(storedSystemFile)
end

function TestUpdateConfig.test_update_conf_arg()
Expand Down

0 comments on commit 10f0740

Please sign in to comment.