summaryrefslogtreecommitdiff
path: root/Command/Unannex.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-10-28 16:56:01 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-10-28 16:56:01 -0400
commit39163cb024b49a0214c104d4fe21b778bbd63eaa (patch)
treed6ff5978d5cac09dac14231a5d423a6784102dfa /Command/Unannex.hs
parentd93d453c3c4d41d446970db21b1d504b3690adb6 (diff)
unannex: New, much slower, but more safe behavior
Copies files out of the annex. This avoids an unannex of one file breaking other files that link to the same content. Also, it means that the content remains in the annex using up space until cleaned up with "git annex unused". (The behavior of unannex --fast has not changed; it still hard links to content in the annex. --fast was not made the default because it is potentially unsafe; editing such a hard linked file can unexpectedly change content stored in the annex.)
Diffstat (limited to 'Command/Unannex.hs')
-rw-r--r--Command/Unannex.hs30
1 files changed, 13 insertions, 17 deletions
diff --git a/Command/Unannex.hs b/Command/Unannex.hs
index 66665f494..5e3c4279a 100644
--- a/Command/Unannex.hs
+++ b/Command/Unannex.hs
@@ -13,11 +13,11 @@ import Common.Annex
import Command
import Config
import qualified Annex
-import Logs.Location
import Annex.Content
import Annex.Content.Direct
import qualified Git.Command
import qualified Git.LsFiles as LsFiles
+import Utility.CopyFile
def :: [Command]
def = [command "unannex" paramPaths seek SectionUtility
@@ -60,28 +60,24 @@ performIndirect file key = do
cleanupIndirect :: FilePath -> Key -> CommandCleanup
cleanupIndirect file key = do
+ src <- calcRepo $ gitAnnexLocation key
ifM (Annex.getState Annex.fast)
- ( goFast
- , go
+ ( hardlinkfrom src
+ , copyfrom src
)
- return True
where
-#ifdef mingw32_HOST_OS
- goFast = go
-#else
- goFast = do
- -- fast mode: hard link to content in annex
- src <- calcRepo $ gitAnnexLocation key
- -- creating a hard link could fall; fall back to non fast mode
+ copyfrom src =
+ thawContent file `after` liftIO (copyFileExternal src file)
+ hardlinkfrom src =
+#ifndef mingw32_HOST_OS
+ -- creating a hard link could fall; fall back to copying
ifM (liftIO $ catchBoolIO $ createLink src file >> return True)
- ( thawContent file
- , go
+ ( return True
+ , copyfrom src
)
+#else
+ copyfrom src
#endif
- go = do
- fromAnnex key file
- logStatus key InfoMissing
-
performDirect :: FilePath -> Key -> CommandPerform
performDirect file key = do