Skip to content

Commit

Permalink
Try unlink(), and check exists() after if it fails.
Browse files Browse the repository at this point in the history
This should handle broken symlinks better than checking exists() first before
 attempting to unlink().

Fixes Bugzilla #3941, I think.
  • Loading branch information
icculus committed Feb 5, 2009
1 parent 85e25a0 commit 76640fa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scripts/mojosetup_mainline.lua
Expand Up @@ -148,11 +148,13 @@ local function do_delete(fname)
if fname == nil then
retval = true
else
if not MojoSetup.platform.exists(fname) then
retval = true
elseif MojoSetup.platform.unlink(fname) then
-- Try to unlink() first, so we'll catch broken symlinks, then try
-- exists(): if it really wasn't there, we'll call it success anyhow.
if MojoSetup.platform.unlink(fname) then
MojoSetup.loginfo("Deleted '" .. fname .. "'")
retval = true
elseif not MojoSetup.platform.exists(fname) then
retval = true
end
end
return retval
Expand Down

0 comments on commit 76640fa

Please sign in to comment.