diff options
author | Joey Hess <joey@kitenet.net> | 2011-06-20 22:38:18 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-06-20 22:38:18 -0400 |
commit | 9f9e17aa0f4898063a58c88661bca01465b126a9 (patch) | |
tree | 93145a4538c8e35a2223ed106a2475dc7faf4e2a /Command | |
parent | 53706ad9bf9bf22359154edab0ca61acea9027e1 (diff) |
unlock: Made atomic.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Unlock.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Command/Unlock.hs b/Command/Unlock.hs index 161df2ddf..ca8b62502 100644 --- a/Command/Unlock.hs +++ b/Command/Unlock.hs @@ -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!" |