aboutsummaryrefslogtreecommitdiff
path: root/Remote/GCrypt.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-08-04 09:35:57 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-08-04 09:35:57 -0400
commitbee89cf9d62c36e3f13c5e53de3fd253fed157b1 (patch)
tree8daafd975612bf220e097c3c109e66afce7d7dc0 /Remote/GCrypt.hs
parent50b340b84bee12ba1a19a747aef442594aedcbd4 (diff)
make local gcrypt storeKey be atomic
Reuse Remote.Directory's code.
Diffstat (limited to 'Remote/GCrypt.hs')
-rw-r--r--Remote/GCrypt.hs14
1 files changed, 6 insertions, 8 deletions
diff --git a/Remote/GCrypt.hs b/Remote/GCrypt.hs
index a0292a954..d969e02f8 100644
--- a/Remote/GCrypt.hs
+++ b/Remote/GCrypt.hs
@@ -306,14 +306,12 @@ store :: Remote -> Remote.Rsync.RsyncOpts -> Storer
store r rsyncopts
| not $ Git.repoIsUrl (repo r) =
byteStorer $ \k b p -> guardUsable (repo r) False $ liftIO $ do
- let f = gCryptLocation r k
- let d = parentDir f
- createDirectoryIfMissing True d
- allowWrite d
- void $ liftIO $ tryIO $ allowWrite f
- meteredWriteFile p f b
- preventWrite f
- preventWrite d
+ let tmpdir = Git.repoLocation (repo r) </> "tmp" </> keyFile k
+ void $ tryIO $ createDirectoryIfMissing True tmpdir
+ let tmpf = tmpdir </> keyFile k
+ meteredWriteFile p tmpf b
+ let destdir = parentDir $ gCryptLocation r k
+ Remote.Directory.finalizeStoreGeneric tmpdir destdir
return True
| Git.repoIsSsh (repo r) = if isShell r
then fileStorer $ \k f p -> Ssh.rsyncHelper (Just p)