improve thirdpartypopulated support

May actually work now.

Note that, importKey now has to add the size to the key if it's supposed
to have size. Remote.Directory relied on the importer adding the size,
which is no longer done, so it was changed; it was the only one.
This way, importKey does not need to behave differently between regular
and thirdpartypopulated imports.
This commit is contained in:
Joey Hess 2020-12-21 16:03:27 -04:00
parent 57b03630b3
commit 15000dee07
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 56 additions and 50 deletions

View file

@ -77,7 +77,6 @@ import Utility.Process.Transcript
import Utility.Tuple
import Control.Concurrent.MVar
import Control.Concurrent.STM
import qualified Data.Map as M
import qualified Data.ByteString as S
import Data.Char
@ -492,24 +491,18 @@ importRemote importcontent o mergeconfig remote currbranch
- updated, because the filenames are the names of annex object files,
- not suitable for a tracking branch. Does not transfer any content. -}
importThirdPartyPopulated :: Remote -> CommandSeek
importThirdPartyPopulated remote = do
importabletvar <- liftIO $ newTVarIO Nothing
void $ includeCommandAction (Command.Import.listContents remote ImportTree (CheckGitIgnore False) importabletvar)
liftIO (atomically (readTVar importabletvar)) >>= \case
Nothing -> return ()
Just importable ->
importKeys remote ImportTree False False importable >>= \case
Just importablekeys -> go importablekeys
Nothing -> warning $ concat
[ "Failed to import from"
, Remote.name remote
]
importThirdPartyPopulated remote =
void $ includeCommandAction $ starting "list" ai si $
Command.Import.listContents' remote ImportTree (CheckGitIgnore False) go
where
go importablekeys = void $ includeCommandAction $ starting "pull" ai si $ do
(_imported, updatestate) <- recordImportTree remote ImportTree importablekeys
next $ do
updatestate
return True
go importable = importKeys remote ImportTree False True importable >>= \case
Just importablekeys -> do
(_imported, updatestate) <- recordImportTree remote ImportTree importablekeys
next $ do
updatestate
return True
Nothing -> next $ return False
ai = ActionItemOther (Just (Remote.name remote))
si = SeekInput []