Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
32b906ef
Commit
32b906ef
authored
Dec 14, 2007
by
Simon Marlow
Browse files
always try to remove the new file before restoring the old one (
#1963
)
parent
18b15542
Changes
1
Hide whitespace changes
Inline
Side-by-side
utils/ghc-pkg/Main.hs
View file @
32b906ef
...
...
@@ -693,17 +693,16 @@ savingOldConfig filename io = Exception.block $ do
`
Exception
.
catch
`
\
e
->
do
hPutStr
stdout
(
"WARNING: an error was encountered while writing "
++
"the new configuration.
\n
"
)
if
restore_on_error
then
do
-- remove any partially complete new version:
try
(
removeFile
filename
)
-- and attempt to restore the old one, if we had one:
when
restore_on_error
$
do
hPutStr
stdout
"Attempting to restore the old configuration... "
do
renameFile
oldFile
filename
hPutStrLn
stdout
"done."
`
catch
`
\
err
->
hPutStrLn
stdout
(
"Failed: "
++
show
err
)
else
do
-- file did not exist before, so the new one which
-- might be partially complete.
try
(
removeFile
filename
)
return
()
-- Note the above renameFile sometimes fails on Windows with
-- "permission denied", I have no idea why --SDM.
Exception
.
throwIO
e
-----------------------------------------------------------------------------
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment