summaryrefslogtreecommitdiff
path: root/Command/Add.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-06-15 22:16:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-06-15 22:16:00 -0400
commite32dda07ca739d2fcab7a764916643d247e94a1b (patch)
treed34ec491471faa6d70be71d3be62c59e17b81a8f /Command/Add.hs
parent1bae56e4a09533b777b8c2b58c551a11e36749de (diff)
better temp file handling
Diffstat (limited to 'Command/Add.hs')
-rw-r--r--Command/Add.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index 323d1ed1e..df57ba6cd 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -55,11 +55,10 @@ lockDown file = do
liftIO $ preventWrite file
tmp <- fromRepo gitAnnexTmpDir
createAnnexDirectory tmp
- pid <- liftIO getProcessID
- let tmpfile = tmp </> "add" ++ show pid ++ "." ++ takeFileName file
- liftIO $ nukeFile tmpfile
- liftIO $ createLink file tmpfile
- return $ KeySource { keyFilename = file , contentLocation = tmpfile }
+ liftIO $ do
+ (tmpfile, _handle) <- openTempFile tmp (takeFileName file)
+ createLink file tmpfile
+ return $ KeySource { keyFilename = file , contentLocation = tmpfile }
{- Moves a locked down file into the annex. -}
ingest :: KeySource -> Annex (Maybe Key)