summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-07-11 14:52:53 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-07-11 14:52:53 -0400
commit4d925d77c2af45ac655f2246890f5f12ecef728e (patch)
tree37ae14c9abb7a62f61fbfcec7b9e204f71d13f99
parent5886bcd2a804dc7b5c3285bfbfe86fe3516a0b6e (diff)
uninit: Avoid failing final removal in some direct mode repositories due to file modes.
Specifically .map files.
-rw-r--r--Command/Uninit.hs11
-rw-r--r--Test.hs9
-rw-r--r--debian/changelog2
-rw-r--r--doc/bugs/__171__uninit__187___on_direct_mode_repo_gives___171__removeLink:_permission_denied___40__Permission_denied__41____187__.mdwn1
4 files changed, 16 insertions, 7 deletions
diff --git a/Command/Uninit.hs b/Command/Uninit.hs
index 76022df26..4433de6d0 100644
--- a/Command/Uninit.hs
+++ b/Command/Uninit.hs
@@ -16,6 +16,10 @@ import qualified Command.Unannex
import qualified Annex.Branch
import Annex.Content
import Annex.Init
+import Utility.FileMode
+
+import System.IO.HVFS
+import System.IO.HVFS.Utils
def :: [Command]
def = [addCheck check $ command "uninit" paramPaths seek
@@ -56,6 +60,7 @@ finish = do
annexdir <- fromRepo gitAnnexDir
annexobjectdir <- fromRepo gitAnnexObjectDir
leftovers <- removeUnannexed =<< getKeysPresent InAnnex
+ liftIO $ prepareRemoveAnnexDir annexdir
if null leftovers
then liftIO $ removeDirectoryRecursive annexdir
else error $ unlines
@@ -82,6 +87,12 @@ finish = do
[Param "branch", Param "-D", Param $ Git.fromRef Annex.Branch.name]
liftIO exitSuccess
+{- Turn on write bits in all remaining files in the annex directory, in
+ - preparation for removal. -}
+prepareRemoveAnnexDir :: FilePath -> IO ()
+prepareRemoveAnnexDir annexdir =
+ recurseDir SystemFS annexdir >>= mapM_ (void . tryIO . allowWrite)
+
{- Keys that were moved out of the annex have a hard link still in the
- annex, with > 1 link count, and those can be removed.
-
diff --git a/Test.hs b/Test.hs
index 4e7d6df75..39da14e65 100644
--- a/Test.hs
+++ b/Test.hs
@@ -22,9 +22,7 @@ import qualified Options.Applicative.Types as Opt
#endif
import Control.Exception.Extensible
import qualified Data.Map as M
-import System.IO.HVFS (SystemFS(..))
import qualified Text.JSON
-import System.Path
import Common
@@ -78,6 +76,7 @@ import qualified Utility.Hash
import qualified Utility.Scheduled
import qualified Utility.HumanTime
import qualified Utility.ThreadScheduler
+import qualified Command.Uninit
#ifndef mingw32_HOST_OS
import qualified CmdLine.GitAnnex as GitAnnex
import qualified Remote.Helper.Encryptable
@@ -1492,11 +1491,7 @@ cleanup = cleanup' False
cleanup' :: Bool -> FilePath -> IO ()
cleanup' final dir = whenM (doesDirectoryExist dir) $ do
- -- Allow all files and directories to be written to, so
- -- they can be deleted. Both git and git-annex use file
- -- permissions to prevent deletion.
- recurseDir SystemFS dir >>=
- mapM_ (void . tryIO . Utility.FileMode.allowWrite)
+ Command.Uninit.prepareRemoveAnnexDir dir
-- This sometimes fails on Windows, due to some files
-- being still opened by a subprocess.
catchIO (removeDirectoryRecursive dir) $ \e ->
diff --git a/debian/changelog b/debian/changelog
index 087e3cdfc..58f2430b7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,8 @@ git-annex (5.20140710) UNRELEASED; urgency=medium
* direct: Fix handling of case where a work tree subdirectory cannot
be written to due to permissions.
* migrate: Avoid re-checksumming when migrating from hashE to hash backend.
+ * uninit: Avoid failing final removal in some direct mode repositories
+ due to file modes.
-- Joey Hess <joeyh@debian.org> Wed, 09 Jul 2014 23:29:21 -0400
diff --git a/doc/bugs/__171__uninit__187___on_direct_mode_repo_gives___171__removeLink:_permission_denied___40__Permission_denied__41____187__.mdwn b/doc/bugs/__171__uninit__187___on_direct_mode_repo_gives___171__removeLink:_permission_denied___40__Permission_denied__41____187__.mdwn
index b0af89554..b7dcf29b7 100644
--- a/doc/bugs/__171__uninit__187___on_direct_mode_repo_gives___171__removeLink:_permission_denied___40__Permission_denied__41____187__.mdwn
+++ b/doc/bugs/__171__uninit__187___on_direct_mode_repo_gives___171__removeLink:_permission_denied___40__Permission_denied__41____187__.mdwn
@@ -30,3 +30,4 @@ linux 3.15.5
### Please provide any additional information below.
+> [[fixed|done]] --[[Joey]]