fix storeExportWithContentIdentifier
This commit is contained in:
parent
88bb928f22
commit
cd86692c95
1 changed files with 21 additions and 21 deletions
|
@ -145,26 +145,23 @@ store serial adir = fileStorer $ \k src _p ->
|
||||||
in store' serial dest src
|
in store' serial dest src
|
||||||
|
|
||||||
store' :: AndroidSerial -> AndroidPath -> FilePath -> Annex Bool
|
store' :: AndroidSerial -> AndroidPath -> FilePath -> Annex Bool
|
||||||
store' serial dest src = store'' serial dest src False (return (Just True))
|
store' serial dest src = store'' serial dest src (return True)
|
||||||
|
|
||||||
store'' :: AndroidSerial -> AndroidPath -> FilePath -> a -> Annex (Maybe a) -> Annex a
|
store'' :: AndroidSerial -> AndroidPath -> FilePath -> Annex Bool -> Annex Bool
|
||||||
store'' serial dest src onfail postcheck = do
|
store'' serial dest src canoverwrite = do
|
||||||
let destdir = takeDirectory $ fromAndroidPath dest
|
let destdir = takeDirectory $ fromAndroidPath dest
|
||||||
liftIO $ void $ adbShell serial [Param "mkdir", Param "-p", File destdir]
|
liftIO $ void $ adbShell serial [Param "mkdir", Param "-p", File destdir]
|
||||||
showOutput -- make way for adb push output
|
showOutput -- make way for adb push output
|
||||||
let tmpdest = fromAndroidPath dest ++ ".annextmp"
|
let tmpdest = fromAndroidPath dest ++ ".annextmp"
|
||||||
ifM (liftIO $ boolSystem "adb" (mkAdbCommand serial [Param "push", File src, File tmpdest]))
|
ifM (liftIO $ boolSystem "adb" (mkAdbCommand serial [Param "push", File src, File tmpdest]))
|
||||||
( postcheck >>= \case
|
( ifM canoverwrite
|
||||||
Just r ->
|
-- move into place atomically
|
||||||
-- move into place atomically
|
( liftIO $ adbShellBool serial [Param "mv", File tmpdest, File (fromAndroidPath dest)]
|
||||||
ifM (liftIO $ adbShellBool serial [Param "mv", File tmpdest, File (fromAndroidPath dest)])
|
, do
|
||||||
( return r
|
|
||||||
, return onfail
|
|
||||||
)
|
|
||||||
Nothing -> do
|
|
||||||
void $ remove' serial (AndroidPath tmpdest)
|
void $ remove' serial (AndroidPath tmpdest)
|
||||||
return onfail
|
return False
|
||||||
, return onfail
|
)
|
||||||
|
, return False
|
||||||
)
|
)
|
||||||
|
|
||||||
retrieve :: AndroidSerial -> AndroidPath -> Retriever
|
retrieve :: AndroidSerial -> AndroidPath -> Retriever
|
||||||
|
@ -298,18 +295,21 @@ storeExportWithContentIdentifierM :: AndroidSerial -> AndroidPath -> FilePath ->
|
||||||
storeExportWithContentIdentifierM serial adir src _k loc overwritablecids _p = catchDefaultIO Nothing $
|
storeExportWithContentIdentifierM serial adir src _k loc overwritablecids _p = catchDefaultIO Nothing $
|
||||||
-- Check if overwrite is safe before sending, because sending the
|
-- Check if overwrite is safe before sending, because sending the
|
||||||
-- file is expensive and don't want to do it unncessarily.
|
-- file is expensive and don't want to do it unncessarily.
|
||||||
liftIO (getExportContentIdentifier serial adir loc) >>= \case
|
ifM checkcanoverwrite
|
||||||
Right Nothing -> go
|
( ifM (store'' serial dest src checkcanoverwrite)
|
||||||
Right (Just cid) | cid `elem` overwritablecids -> go
|
( liftIO $ either (const Nothing) id
|
||||||
_ -> return Nothing
|
<$> getExportContentIdentifier serial adir loc
|
||||||
|
, return Nothing
|
||||||
|
)
|
||||||
|
, return Nothing
|
||||||
|
)
|
||||||
where
|
where
|
||||||
go = store'' serial dest src Nothing checkcanoverwrite
|
|
||||||
dest = androidExportLocation adir loc
|
dest = androidExportLocation adir loc
|
||||||
checkcanoverwrite = liftIO $
|
checkcanoverwrite = liftIO $
|
||||||
getExportContentIdentifier serial adir loc >>= return . \case
|
getExportContentIdentifier serial adir loc >>= return . \case
|
||||||
Right (Just cid) | cid `elem` overwritablecids ->
|
Right (Just cid) | cid `elem` overwritablecids -> True
|
||||||
Just (Just cid)
|
Right Nothing -> True
|
||||||
_ -> Nothing
|
_ -> False
|
||||||
|
|
||||||
removeExportWithContentIdentifierM :: AndroidSerial -> AndroidPath -> Key -> ExportLocation -> [ContentIdentifier] -> Annex Bool
|
removeExportWithContentIdentifierM :: AndroidSerial -> AndroidPath -> Key -> ExportLocation -> [ContentIdentifier] -> Annex Bool
|
||||||
removeExportWithContentIdentifierM serial adir k loc removeablecids = catchBoolIO $
|
removeExportWithContentIdentifierM serial adir k loc removeablecids = catchBoolIO $
|
||||||
|
|
Loading…
Add table
Reference in a new issue