summaryrefslogtreecommitdiff
path: root/Annex/Content.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-24 12:58:52 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-24 12:58:52 -0400
commitb87811c4b55d66b1edb26c73e6578ca9f2994a65 (patch)
treef41a9b52b1fecaac946814a2ae5a1f303f6a542a /Annex/Content.hs
parent3bb7ecf0d30a8ecb89d075c808f529a7a3ea874b (diff)
added annex.secure-erase-command config option.
Diffstat (limited to 'Annex/Content.hs')
-rw-r--r--Annex/Content.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs
index 316f05be0..7cd2fb561 100644
--- a/Annex/Content.hs
+++ b/Annex/Content.hs
@@ -377,6 +377,7 @@ removeAnnex :: Key -> Annex ()
removeAnnex key = withObjectLoc key remove removedirect
where
remove file = cleanObjectLoc key $ do
+ secureErase file
liftIO $ nukeFile file
removeInodeCache key
removedirect fs = do
@@ -389,8 +390,19 @@ removeAnnex key = withObjectLoc key remove removedirect
cwd <- liftIO getCurrentDirectory
let top' = fromMaybe top $ absNormPath cwd top
let l' = relPathDirToFile top' (fromMaybe l $ absNormPath top' l)
+ secureErase f
replaceFile f $ makeAnnexLink l'
+{- Runs the secure erase command if set, otherwise does nothing.
+ - File may or may not be deleted at the end; caller is responsible for
+ - making sure it's deleted. -}
+secureErase :: FilePath -> Annex ()
+secureErase file = maybe noop go =<< annexSecureEraseCommand <$> Annex.getGitConfig
+ where
+ go basecmd = void $ liftIO $
+ boolSystem "sh" [Param "-c", Param $ gencmd basecmd]
+ gencmd = massReplace [ ("%file", shellEscape file) ]
+
{- Moves a key's file out of .git/annex/objects/ -}
fromAnnex :: Key -> FilePath -> Annex ()
fromAnnex key dest = cleanObjectLoc key $ do