mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2025-01-22 15:31:08 +00:00
Fix file uninstallation and add a test
Prepend the install directory to the file path specified in the <uninstall> section of the XML file to get the path of the file to remove. If the file cannot be uninstalled because it does not exist, log a warning and continue.
This commit is contained in:
parent
dc303201fa
commit
8773a7a622
3 changed files with 22 additions and 7 deletions
|
@ -228,7 +228,15 @@ void UpdateInstaller::uninstallFiles()
|
|||
std::vector<std::string>::const_iterator iter = m_script->filesToUninstall().begin();
|
||||
for (;iter != m_script->filesToUninstall().end();iter++)
|
||||
{
|
||||
FileOps::removeFile(iter->c_str());
|
||||
std::string path = m_installDir + '/' + iter->c_str();
|
||||
if (FileOps::fileExists(path.c_str()))
|
||||
{
|
||||
FileOps::removeFile(path.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(Warn,"Unable to uninstall file " + path + " because it does not exist.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,5 +31,6 @@
|
|||
</install>
|
||||
<uninstall>
|
||||
<!-- TODO - List some files to uninstall here !-->
|
||||
<file>file-to-uninstall.txt</file>
|
||||
</uninstall>
|
||||
</update>
|
||||
|
|
|
@ -14,6 +14,12 @@ FileUtils.rm_rf(PACKAGE_DIR)
|
|||
Dir.mkdir(INSTALL_DIR)
|
||||
FileUtils.cp("oldapp","#{INSTALL_DIR}/app")
|
||||
|
||||
# Create a dummy file to uninstall
|
||||
uninstall_test_file = "#{INSTALL_DIR}/file-to-uninstall.txt"
|
||||
File.open(uninstall_test_file,"w") do |file|
|
||||
file.puts "this file should be removed after the update"
|
||||
end
|
||||
|
||||
# Create the update archive containing the new app
|
||||
Dir.mkdir(PACKAGE_DIR)
|
||||
FileUtils.cp("newapp","#{PACKAGE_DIR}/app")
|
||||
|
@ -33,11 +39,11 @@ sleep(1)
|
|||
|
||||
# Check that the app was updated
|
||||
output = `#{INSTALL_DIR}/app`
|
||||
if (output.strip == "new app starting")
|
||||
puts "Updated app produced expected output"
|
||||
exit(0)
|
||||
else
|
||||
puts "Updated app produced unexpected output: #{output}"
|
||||
exit(1)
|
||||
if (output.strip != "new app starting")
|
||||
throw "Updated app produced unexpected output: #{output}"
|
||||
end
|
||||
|
||||
if (File.exist?(uninstall_test_file))
|
||||
throw "File to uninstall was not removed"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue