From: Joey Hess Date: Tue, 11 Jan 2022 01:15:30 +0000 (-0400) Subject: adb: Added ignorefinderror configuration parameter X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~2^2^2~53^2~356 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=525473aa5a49097f8fc55e49d6b66245bce3e5e6;p=git-annex.git adb: Added ignorefinderror configuration parameter On a phone with Calyxos, adb find in /sdcard complains: find: ./Android/data/com.android.providers.downloads.ui: Permission denied But otherwise works, so this option makes import and export work ok, except for that one app's data. Sponsored-by: Graham Spencer --- diff --git a/CHANGELOG b/CHANGELOG index 79d655a6b4..16cd4f0098 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ git-annex (8.20211232) UNRELEASED; urgency=medium by deleting the temporary file when it fails to verify. This prevents a retry from failing again. (reversion introduced in version 8.20210903) + * adb: Added ignorefinderror configuration parameter. -- Joey Hess Mon, 03 Jan 2022 14:01:14 -0400 diff --git a/Remote/Adb.hs b/Remote/Adb.hs index 580a640fc5..2001727b11 100644 --- a/Remote/Adb.hs +++ b/Remote/Adb.hs @@ -43,6 +43,8 @@ remote = specialRemoteType $ RemoteType (FieldDesc "location on the Android device where the files are stored") , optionalStringParser androidserialField (FieldDesc "sometimes needed to specify which Android device to use") + , yesNoParser ignorefinderrorField (Just False) + (FieldDesc "ignore adb find errors") ] , setup = adbSetup , exportSupported = exportIsSupported @@ -56,6 +58,10 @@ androiddirectoryField = Accepted "androiddirectory" androidserialField :: RemoteConfigField androidserialField = Accepted "androidserial" +ignorefinderrorField :: RemoteConfigField +ignorefinderrorField = Accepted "ignorefinderror" + + gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote) gen r u rc gc rs = do c <- parsedRemoteConfig remote rc @@ -83,7 +89,7 @@ gen r u rc gc rs = do , renameExport = renameExportM serial adir } , importActions = ImportActions - { listImportableContents = listImportableContentsM serial adir + { listImportableContents = listImportableContentsM serial adir c , importKey = Nothing , retrieveExportWithContentIdentifier = retrieveExportWithContentIdentifierM serial adir , storeExportWithContentIdentifier = storeExportWithContentIdentifierM serial adir @@ -289,13 +295,13 @@ renameExportM serial adir _k old new = do , File newloc ] -listImportableContentsM :: AndroidSerial -> AndroidPath -> Annex (Maybe (ImportableContentsChunkable Annex (ContentIdentifier, ByteSize))) -listImportableContentsM serial adir = adbfind >>= \case +listImportableContentsM :: AndroidSerial -> AndroidPath -> ParsedRemoteConfig -> Annex (Maybe (ImportableContentsChunkable Annex (ContentIdentifier, ByteSize))) +listImportableContentsM serial adir c = adbfind >>= \case Just ls -> return $ Just $ ImportableContentsComplete $ ImportableContents (mapMaybe mk ls) [] Nothing -> giveup "adb find failed" where - adbfind = adbShell serial + adbfind = adbShell' serial [ Param "find" -- trailing slash is needed, or android's find command -- won't recurse into the directory @@ -304,7 +310,10 @@ listImportableContentsM serial adir = adbfind >>= \case , Param "-exec", Param "stat" , Param "-c", Param statformat , Param "{}", Param "+" - ] + ] + (if ignorefinderror then "|| true" else "") + + ignorefinderror = fromMaybe False (getRemoteConfigValue ignorefinderrorField c) statformat = adbStatFormat ++ "\t%n" @@ -390,8 +399,11 @@ enumerateAdbConnected = checkAdbInPath [] $ liftIO $ -- -- Any stdout from the command is returned, separated into lines. adbShell :: AndroidSerial -> [CommandParam] -> Annex (Maybe [String]) -adbShell serial cmd = adbShellRaw serial $ - unwords $ map shellEscape (toCommand cmd) +adbShell serial cmd = adbShell' serial cmd "" + +adbShell' :: AndroidSerial -> [CommandParam] -> String -> Annex (Maybe [String]) +adbShell' serial cmd extra = adbShellRaw serial $ + (unwords $ map shellEscape (toCommand cmd)) ++ extra adbShellBool :: AndroidSerial -> [CommandParam] -> Annex Bool adbShellBool serial cmd = diff --git a/doc/special_remotes/adb.mdwn b/doc/special_remotes/adb.mdwn index 4eed62daf3..44f0f79e90 100644 --- a/doc/special_remotes/adb.mdwn +++ b/doc/special_remotes/adb.mdwn @@ -32,6 +32,10 @@ the adb remote. by [[git-annex-import]]. When set in combination with exporttree, this lets files be imported from it, and changes exported back to it. +* `ignorefinderror` - Set to "yes" to ignore errors when running "adb find" + on the Android device. This can be useful eg, if some subdirectories are + not readable, to let it import the other things that are readable. + * `encryption` - One of "none", "hybrid", "shared", or "pubkey". See [[encryption]].