fix remote fsck to run in remote
This commit is contained in:
parent
c78aaed317
commit
a6e9386d39
2 changed files with 18 additions and 6 deletions
|
@ -42,6 +42,7 @@ import Utility.Metered
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
import Utility.CopyFile
|
import Utility.CopyFile
|
||||||
#endif
|
#endif
|
||||||
|
import Utility.Env
|
||||||
import Utility.Batch
|
import Utility.Batch
|
||||||
import Remote.Helper.Git
|
import Remote.Helper.Git
|
||||||
import Remote.Helper.Messages
|
import Remote.Helper.Messages
|
||||||
|
@ -410,7 +411,13 @@ fsckOnRemote r params
|
||||||
Just (c, ps) -> batchCommand c ps
|
Just (c, ps) -> batchCommand c ps
|
||||||
| otherwise = return $ do
|
| otherwise = return $ do
|
||||||
program <- readProgramFile
|
program <- readProgramFile
|
||||||
batchCommand program $ Param "fsck" : params
|
env <- getEnvironment
|
||||||
|
r' <- Git.Config.read r
|
||||||
|
let env' =
|
||||||
|
[ ("GIT_WORK_TREE", Git.repoPath r')
|
||||||
|
, ("GIT_DIR", Git.localGitDir r')
|
||||||
|
] ++ env
|
||||||
|
batchCommandEnv program (Param "fsck" : params) (Just env')
|
||||||
|
|
||||||
{- Runs an action on a local repository inexpensively, by making an annex
|
{- Runs an action on a local repository inexpensively, by making an annex
|
||||||
- monad using that repository. -}
|
- monad using that repository. -}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import Control.Concurrent.Async
|
||||||
import System.Posix.Process
|
import System.Posix.Process
|
||||||
#endif
|
#endif
|
||||||
import qualified Control.Exception as E
|
import qualified Control.Exception as E
|
||||||
|
import System.Process (env)
|
||||||
|
|
||||||
{- Runs an operation, at batch priority.
|
{- Runs an operation, at batch priority.
|
||||||
-
|
-
|
||||||
|
@ -48,11 +49,11 @@ maxNice = 19
|
||||||
- exception, it sends the command a SIGTERM, and after the command
|
- exception, it sends the command a SIGTERM, and after the command
|
||||||
- finishes shuttting down, it re-raises the async exception. -}
|
- finishes shuttting down, it re-raises the async exception. -}
|
||||||
batchCommand :: String -> [CommandParam] -> IO Bool
|
batchCommand :: String -> [CommandParam] -> IO Bool
|
||||||
batchCommand command params = do
|
batchCommand command params = batchCommandEnv command params Nothing
|
||||||
(_, _, _, pid) <- createProcess $ proc "sh"
|
|
||||||
[ "-c"
|
batchCommandEnv :: String -> [CommandParam] -> Maybe [(String, String)] -> IO Bool
|
||||||
, "exec " ++ nicedcommand
|
batchCommandEnv command params environ = do
|
||||||
]
|
(_, _, _, pid) <- createProcess $ p { env = environ }
|
||||||
r <- E.try (waitForProcess pid) :: IO (Either E.SomeException ExitCode)
|
r <- E.try (waitForProcess pid) :: IO (Either E.SomeException ExitCode)
|
||||||
case r of
|
case r of
|
||||||
Right ExitSuccess -> return True
|
Right ExitSuccess -> return True
|
||||||
|
@ -62,6 +63,10 @@ batchCommand command params = do
|
||||||
void $ waitForProcess pid
|
void $ waitForProcess pid
|
||||||
E.throwIO asyncexception
|
E.throwIO asyncexception
|
||||||
where
|
where
|
||||||
|
p = proc "sh"
|
||||||
|
[ "-c"
|
||||||
|
, "exec " ++ nicedcommand
|
||||||
|
]
|
||||||
commandline = unwords $ map shellEscape $ command : toCommand params
|
commandline = unwords $ map shellEscape $ command : toCommand params
|
||||||
nicedcommand
|
nicedcommand
|
||||||
| Build.SysConfig.nice = "nice " ++ commandline
|
| Build.SysConfig.nice = "nice " ++ commandline
|
||||||
|
|
Loading…
Reference in a new issue