[mojosetup] [10/13] Fix handling of rollbacks when a file or symbolic link replaces a directory on upgrade.
Francois Gouget
fgouget at codeweavers.com
Mon May 21 14:39:15 EDT 2012
First we must make sure not to move non-empty directories to the rollback directory. Otherwise we would be unable to rmdir them when clearing the rollbacks.
Furthermore we must make sure to mark all their content as seen so we don't try to delete it as 'obsolete' later on. This is critical when a directory is replaced by a symbolic link pointing to a directory that may well contain the same set of files.
---
This depends on patch 9 and patch 2.
scripts/mojosetup_mainline.lua | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/scripts/mojosetup_mainline.lua b/scripts/mojosetup_mainline.lua
index 163f545..da7e18d 100644
--- a/scripts/mojosetup_mainline.lua
+++ b/scripts/mojosetup_mainline.lua
@@ -516,6 +516,19 @@ end
local function backup_file(path)
+ if MojoSetup.platform.isdir(path) and
+ not MojoSetup.platform.issymlink(path) then
+ -- We must first create rollbacks for all the files and directories
+ -- contained in this directory
+ local dir = MojoSetup.platform.opendir(path)
+ local dentry = MojoSetup.platform.readdir(dir)
+ while dentry ~= nil do
+ backup_file(path .. "/" .. dentry)
+ dentry = MojoSetup.platform.readdir(dir)
+ end
+ MojoSetup.platform.closedir(dir)
+ end
+
local id = #MojoSetup.rollbacks + 1
local f = MojoSetup.rollbackdir .. "/" .. id
install_parent_dirs(f, MojoSetup.metadatakey)
@@ -523,6 +536,13 @@ local function backup_file(path)
if not MojoSetup.movefile(path, f) then
MojoSetup.fatal(_("Couldn't backup '" .. path .. "' to '" .. f .. "' for rollback"))
end
+ relpath = make_relative(path, MojoSetup.destination)
+ if MojoSetup.oldfiles[relpath] ~= nil then
+ MojoSetup.oldfiles[relpath].seen = 1
+ MojoSetup.loginfo("marked '" .. relpath .. "' as seen")
+ else
+ MojoSetup.loginfo(relpath .. " is not an old file")
+ end
MojoSetup.loginfo("Created rollback #" .. id .. ": '" .. path .. "'")
end
--
1.7.10
More information about the mojosetup
mailing list