diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-12-11 15:13:36 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-12-11 15:28:34 -0400 |
commit | f1e51105f413082e3d9136330360a54f7cf3c248 (patch) | |
tree | 31b94a25887cc038b157947d2041a0ebe7dd3761 /Annex | |
parent | e43f7a080838c87df1e63b5a58875561157a5a85 (diff) |
finish v6 git-annex lock
This was a doozy!
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/Content.hs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs index 756c801ad..f0c8e25cd 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -27,6 +27,7 @@ module Annex.Content ( linkAnnex, linkAnnex', LinkAnnexResult(..), + checkedCopyFile, sendAnnex, prepSendAnnex, removeAnnex, @@ -549,16 +550,25 @@ data LinkAnnexResult = LinkAnnexOk | LinkAnnexFailed | LinkAnnexNoop linkAnnex'' :: Key -> FilePath -> FilePath -> Annex Bool linkAnnex'' key src dest = catchBoolIO $ do s <- liftIO $ getFileStatus src + let copy = checkedCopyFile' key src dest s #ifndef mingw32_HOST_OS if linkCount s > 1 - then copy s + then copy else liftIO (createLink src dest >> return True) - `catchIO` const (copy s) + `catchIO` const copy #else - copy s + copy #endif - where - copy s = ifM (checkDiskSpace' (fromIntegral $ fileSize s) (Just $ takeDirectory dest) key 0 True) + +{- Checks disk space before copying. -} +checkedCopyFile :: Key -> FilePath -> FilePath -> Annex Bool +checkedCopyFile key src dest = catchBoolIO $ + checkedCopyFile' key src dest + =<< liftIO (getFileStatus src) + +checkedCopyFile' :: Key -> FilePath -> FilePath -> FileStatus -> Annex Bool +checkedCopyFile' key src dest s = catchBoolIO $ + ifM (checkDiskSpace' (fromIntegral $ fileSize s) (Just $ takeDirectory dest) key 0 True) ( liftIO $ copyFileExternal CopyAllMetaData src dest , return False ) |