convert listImportableContents to throwing exceptions

This commit is contained in:
Joey Hess 2020-12-22 14:20:11 -04:00
parent 5d8e4a7c74
commit e1ac42be77
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
8 changed files with 27 additions and 27 deletions

View file

@ -286,9 +286,12 @@ renameExportM serial adir _k old new = do
, File newloc
]
listImportableContentsM :: AndroidSerial -> AndroidPath -> Annex (Maybe (ImportableContents (ContentIdentifier, ByteSize)))
listImportableContentsM serial adir =
process <$> adbShell serial
listImportableContentsM :: AndroidSerial -> AndroidPath -> Annex (ImportableContents (ContentIdentifier, ByteSize))
listImportableContentsM serial adir = adbfind >>= \case
Just ls -> return $ ImportableContents (mapMaybe mk ls) []
Nothing -> giveup "adb find failed"
where
adbfind = adbShell serial
[ Param "find"
-- trailing slash is needed, or android's find command
-- won't recurse into the directory
@ -298,9 +301,6 @@ listImportableContentsM serial adir =
, Param "-c", Param statformat
, Param "{}", Param "+"
]
where
process Nothing = Nothing
process (Just ls) = Just $ ImportableContents (mapMaybe mk ls) []
statformat = adbStatFormat ++ "\t%n"