uninit: Avoid failing final removal in some direct mode repositories due to file modes.

Specifically .map files.
This commit is contained in:
Joey Hess 2014-07-11 14:52:53 -04:00
parent ee9ffcd940
commit c5f132e3e7
4 changed files with 16 additions and 7 deletions

View file

@ -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.
-

View file

@ -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 ->

2
debian/changelog vendored
View file

@ -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

View file

@ -30,3 +30,4 @@ linux 3.15.5
### Please provide any additional information below.
> [[fixed|done]] --[[Joey]]