adb: Avoid find failing with "Argument list too long"
The "+" argument only runs the command once, so is not safe to use. Using ";" instead would have been the simplest fix, but also the slowest. Since my phone has an xargs that supports -0, I piped find to xargs instead. Unsure how portable this will be, perhaps some android's don't have xargs -0 or find -printf to send null terminated output. The business with pipefail is necessary to make a failure of find cause the import to fail. Probably this works on all androids, but if not, it will probably just result in a failure of find being ignored. It would be possible to make ignorefinderror just disable setting pipefail, but then if some android has a shell that has pipefail enabled by default, ignorefinderror would not work, so I kept the || true approach for that. Sponsored-by: Max Thoursie on Patreon
This commit is contained in:
parent
8f3d48c5cf
commit
a32ff6cef0
4 changed files with 32 additions and 8 deletions
|
@ -307,11 +307,15 @@ listImportableContentsM serial adir c = adbfind >>= \case
|
|||
-- won't recurse into the directory
|
||||
, File $ fromAndroidPath adir ++ "/"
|
||||
, Param "-type", Param "f"
|
||||
, Param "-exec", Param "stat"
|
||||
, Param "-c", Param statformat
|
||||
, Param "{}", Param "+"
|
||||
, Param "-printf", Param "%p\\0"
|
||||
]
|
||||
(if ignorefinderror then "|| true" else "")
|
||||
(\s -> concat
|
||||
[ "set -o pipefail; "
|
||||
, s
|
||||
, "| xargs -0 stat -c " ++ shellEscape statformat ++ " --"
|
||||
, if ignorefinderror then " || true" else ""
|
||||
]
|
||||
)
|
||||
|
||||
ignorefinderror = fromMaybe False (getRemoteConfigValue ignorefinderrorField c)
|
||||
|
||||
|
@ -399,11 +403,11 @@ enumerateAdbConnected = checkAdbInPath [] $ liftIO $
|
|||
--
|
||||
-- Any stdout from the command is returned, separated into lines.
|
||||
adbShell :: AndroidSerial -> [CommandParam] -> Annex (Maybe [String])
|
||||
adbShell serial cmd = adbShell' serial cmd ""
|
||||
adbShell serial cmd = adbShell' serial cmd id
|
||||
|
||||
adbShell' :: AndroidSerial -> [CommandParam] -> String -> Annex (Maybe [String])
|
||||
adbShell' serial cmd extra = adbShellRaw serial $
|
||||
(unwords $ map shellEscape (toCommand cmd)) ++ extra
|
||||
adbShell' :: AndroidSerial -> [CommandParam] -> (String -> String) -> Annex (Maybe [String])
|
||||
adbShell' serial cmd f = adbShellRaw serial $
|
||||
f (unwords $ map shellEscape (toCommand cmd))
|
||||
|
||||
adbShellBool :: AndroidSerial -> [CommandParam] -> Annex Bool
|
||||
adbShellBool serial cmd =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue