summaryrefslogtreecommitdiff
path: root/Command/Unlock.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-06-20 22:38:18 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-06-20 22:38:18 -0400
commit9f9e17aa0f4898063a58c88661bca01465b126a9 (patch)
tree93145a4538c8e35a2223ed106a2475dc7faf4e2a /Command/Unlock.hs
parent53706ad9bf9bf22359154edab0ca61acea9027e1 (diff)
unlock: Made atomic.
Diffstat (limited to 'Command/Unlock.hs')
-rw-r--r--Command/Unlock.hs10
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!"