unlock: Made atomic.
This commit is contained in:
parent
53706ad9bf
commit
9f9e17aa0f
3 changed files with 10 additions and 3 deletions
|
@ -44,11 +44,15 @@ perform dest key = do
|
|||
|
||||
g <- Annex.gitRepo
|
||||
let src = gitAnnexLocation g key
|
||||
liftIO $ removeFile dest
|
||||
let tmpdest = gitAnnexTmpLocation g key
|
||||
liftIO $ createDirectoryIfMissing True (parentDir tmpdest)
|
||||
showNote "copying..."
|
||||
ok <- liftIO $ copyFile src dest
|
||||
ok <- liftIO $ copyFile src tmpdest
|
||||
if ok
|
||||
then do
|
||||
liftIO $ allowWrite dest
|
||||
liftIO $ do
|
||||
removeFile dest
|
||||
renameFile tmpdest dest
|
||||
allowWrite dest
|
||||
next $ return True
|
||||
else error "copy failed!"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue