startExternalAddonProcess add parameters

Not used yet but intended to support eg running "rclone gitannex"
This commit is contained in:
Joey Hess 2024-04-17 13:09:10 -04:00
parent 631a3ca05d
commit c64a73c7ea
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 7 additions and 7 deletions

View file

@ -1,6 +1,6 @@
{- External addon processes for special remotes and backends. {- External addon processes for special remotes and backends.
- -
- Copyright 2013-2020 Joey Hess <id@joeyh.name> - Copyright 2013-2024 Joey Hess <id@joeyh.name>
- -
- Licensed under the GNU AGPL version 3 or higher. - Licensed under the GNU AGPL version 3 or higher.
-} -}
@ -33,16 +33,16 @@ data ExternalAddonStartError
= ProgramNotInstalled String = ProgramNotInstalled String
| ProgramFailure String | ProgramFailure String
startExternalAddonProcess :: String -> ExternalAddonPID -> Annex (Either ExternalAddonStartError ExternalAddonProcess) startExternalAddonProcess :: String -> [CommandParam] -> ExternalAddonPID -> Annex (Either ExternalAddonStartError ExternalAddonProcess)
startExternalAddonProcess basecmd pid = do startExternalAddonProcess basecmd ps pid = do
errrelayer <- mkStderrRelayer errrelayer <- mkStderrRelayer
g <- Annex.gitRepo g <- Annex.gitRepo
cmdpath <- liftIO $ searchPath basecmd cmdpath <- liftIO $ searchPath basecmd
liftIO $ start errrelayer g cmdpath liftIO $ start errrelayer g cmdpath
where where
start errrelayer g cmdpath = do start errrelayer g cmdpath = do
(cmd, ps) <- maybe (pure (basecmd, [])) findShellCommand cmdpath (cmd, cmdps) <- maybe (pure (basecmd, [])) findShellCommand cmdpath
let basep = (proc cmd (toCommand ps)) let basep = (proc cmd (toCommand (cmdps ++ ps)))
{ std_in = CreatePipe { std_in = CreatePipe
, std_out = CreatePipe , std_out = CreatePipe
, std_err = CreatePipe , std_err = CreatePipe

View file

@ -215,7 +215,7 @@ poolVar = unsafePerformIO $ newMVar M.empty
-- using it. -- using it.
newExternalState :: ExternalBackendName -> HasExt -> ExternalAddonPID -> Annex ExternalState newExternalState :: ExternalBackendName -> HasExt -> ExternalAddonPID -> Annex ExternalState
newExternalState ebname hasext pid = do newExternalState ebname hasext pid = do
st <- startExternalAddonProcess basecmd pid st <- startExternalAddonProcess basecmd [] pid
st' <- case st of st' <- case st of
Left (ProgramNotInstalled msg) -> warnonce msg >> return st Left (ProgramNotInstalled msg) -> warnonce msg >> return st
Left (ProgramFailure msg) -> warnonce msg >> return st Left (ProgramFailure msg) -> warnonce msg >> return st

View file

@ -658,7 +658,7 @@ startExternal' external = do
n <- succ <$> readTVar (externalLastPid external) n <- succ <$> readTVar (externalLastPid external)
writeTVar (externalLastPid external) n writeTVar (externalLastPid external) n
return n return n
AddonProcess.startExternalAddonProcess basecmd pid >>= \case AddonProcess.startExternalAddonProcess basecmd [] pid >>= \case
Left (AddonProcess.ProgramFailure err) -> do Left (AddonProcess.ProgramFailure err) -> do
unusable err unusable err
Left (AddonProcess.ProgramNotInstalled err) -> Left (AddonProcess.ProgramNotInstalled err) ->