uninit: Avoid failing final removal in some direct mode repositories due to file modes.
Specifically .map files.
This commit is contained in:
parent
ee9ffcd940
commit
c5f132e3e7
4 changed files with 16 additions and 7 deletions
|
@ -16,6 +16,10 @@ import qualified Command.Unannex
|
||||||
import qualified Annex.Branch
|
import qualified Annex.Branch
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Annex.Init
|
import Annex.Init
|
||||||
|
import Utility.FileMode
|
||||||
|
|
||||||
|
import System.IO.HVFS
|
||||||
|
import System.IO.HVFS.Utils
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [addCheck check $ command "uninit" paramPaths seek
|
def = [addCheck check $ command "uninit" paramPaths seek
|
||||||
|
@ -56,6 +60,7 @@ finish = do
|
||||||
annexdir <- fromRepo gitAnnexDir
|
annexdir <- fromRepo gitAnnexDir
|
||||||
annexobjectdir <- fromRepo gitAnnexObjectDir
|
annexobjectdir <- fromRepo gitAnnexObjectDir
|
||||||
leftovers <- removeUnannexed =<< getKeysPresent InAnnex
|
leftovers <- removeUnannexed =<< getKeysPresent InAnnex
|
||||||
|
liftIO $ prepareRemoveAnnexDir annexdir
|
||||||
if null leftovers
|
if null leftovers
|
||||||
then liftIO $ removeDirectoryRecursive annexdir
|
then liftIO $ removeDirectoryRecursive annexdir
|
||||||
else error $ unlines
|
else error $ unlines
|
||||||
|
@ -82,6 +87,12 @@ finish = do
|
||||||
[Param "branch", Param "-D", Param $ Git.fromRef Annex.Branch.name]
|
[Param "branch", Param "-D", Param $ Git.fromRef Annex.Branch.name]
|
||||||
liftIO exitSuccess
|
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
|
{- 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.
|
- annex, with > 1 link count, and those can be removed.
|
||||||
-
|
-
|
||||||
|
|
9
Test.hs
9
Test.hs
|
@ -22,9 +22,7 @@ import qualified Options.Applicative.Types as Opt
|
||||||
#endif
|
#endif
|
||||||
import Control.Exception.Extensible
|
import Control.Exception.Extensible
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import System.IO.HVFS (SystemFS(..))
|
|
||||||
import qualified Text.JSON
|
import qualified Text.JSON
|
||||||
import System.Path
|
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
|
|
||||||
|
@ -78,6 +76,7 @@ import qualified Utility.Hash
|
||||||
import qualified Utility.Scheduled
|
import qualified Utility.Scheduled
|
||||||
import qualified Utility.HumanTime
|
import qualified Utility.HumanTime
|
||||||
import qualified Utility.ThreadScheduler
|
import qualified Utility.ThreadScheduler
|
||||||
|
import qualified Command.Uninit
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
import qualified CmdLine.GitAnnex as GitAnnex
|
import qualified CmdLine.GitAnnex as GitAnnex
|
||||||
import qualified Remote.Helper.Encryptable
|
import qualified Remote.Helper.Encryptable
|
||||||
|
@ -1492,11 +1491,7 @@ cleanup = cleanup' False
|
||||||
|
|
||||||
cleanup' :: Bool -> FilePath -> IO ()
|
cleanup' :: Bool -> FilePath -> IO ()
|
||||||
cleanup' final dir = whenM (doesDirectoryExist dir) $ do
|
cleanup' final dir = whenM (doesDirectoryExist dir) $ do
|
||||||
-- Allow all files and directories to be written to, so
|
Command.Uninit.prepareRemoveAnnexDir dir
|
||||||
-- they can be deleted. Both git and git-annex use file
|
|
||||||
-- permissions to prevent deletion.
|
|
||||||
recurseDir SystemFS dir >>=
|
|
||||||
mapM_ (void . tryIO . Utility.FileMode.allowWrite)
|
|
||||||
-- This sometimes fails on Windows, due to some files
|
-- This sometimes fails on Windows, due to some files
|
||||||
-- being still opened by a subprocess.
|
-- being still opened by a subprocess.
|
||||||
catchIO (removeDirectoryRecursive dir) $ \e ->
|
catchIO (removeDirectoryRecursive dir) $ \e ->
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -4,6 +4,8 @@ git-annex (5.20140710) UNRELEASED; urgency=medium
|
||||||
* direct: Fix handling of case where a work tree subdirectory cannot
|
* direct: Fix handling of case where a work tree subdirectory cannot
|
||||||
be written to due to permissions.
|
be written to due to permissions.
|
||||||
* migrate: Avoid re-checksumming when migrating from hashE to hash backend.
|
* 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
|
-- Joey Hess <joeyh@debian.org> Wed, 09 Jul 2014 23:29:21 -0400
|
||||||
|
|
||||||
|
|
|
@ -30,3 +30,4 @@ linux 3.15.5
|
||||||
|
|
||||||
### Please provide any additional information below.
|
### Please provide any additional information below.
|
||||||
|
|
||||||
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue