implement retrieveExportWithContentIdentifier
Moved out an XXX to a todo This seems about ready to merge..
This commit is contained in:
parent
a9d639c5b5
commit
4254e2297d
2 changed files with 31 additions and 8 deletions
|
@ -17,6 +17,7 @@ import Git.Types (toTreeItemType, TreeItemType(..))
|
|||
import Git.FilePath
|
||||
import Config
|
||||
import Config.Cost
|
||||
import Annex.Tmp
|
||||
import Annex.SpecialRemote.Config
|
||||
import Remote.Helper.Special
|
||||
import Remote.Helper.ExportImport
|
||||
|
@ -131,9 +132,6 @@ borgLocal = notElem ':'
|
|||
borgArchive :: BorgRepo -> BorgArchiveName -> String
|
||||
borgArchive r n = r ++ "::" ++ decodeBS' n
|
||||
|
||||
-- XXX the tree generated by using this does not seem to get grafted into
|
||||
-- the git-annex branch, so would be subject to being lost to GC.
|
||||
-- Is this a general problem affecting importtree too?
|
||||
listImportableContentsM :: UUID -> BorgRepo -> Annex (Maybe (ImportableContents (ContentIdentifier, ByteSize)))
|
||||
listImportableContentsM u borgrepo = prompt $ do
|
||||
imported <- getImported u
|
||||
|
@ -172,7 +170,7 @@ listImportableContentsM u borgrepo = prompt $ do
|
|||
-- importable keys, so avoids needing to buffer all
|
||||
-- the rest of the files in memory.
|
||||
in case ThirdPartyPopulated.importKey' loc sz of
|
||||
Just k -> (loc, (borgContentIdentifier, sz))
|
||||
Just _k -> (loc, (borgContentIdentifier, sz))
|
||||
: parsefilelist archivename rest
|
||||
Nothing -> parsefilelist archivename rest
|
||||
parsefilelist _ _ = []
|
||||
|
@ -249,15 +247,12 @@ getImported u = M.unions <$> (mapM go . exportedTreeishes =<< getExport u)
|
|||
)
|
||||
)
|
||||
|
||||
retrieveExportWithContentIdentifierM :: BorgRepo -> ImportLocation -> ContentIdentifier -> FilePath -> Annex Key -> MeterUpdate -> Annex Key
|
||||
retrieveExportWithContentIdentifierM borgrepo loc cid dest k p = error "TODO"
|
||||
|
||||
-- Check if the file is still there in the borg archive.
|
||||
-- Does not check that the content is unchanged; we assume that
|
||||
-- the content of files in borg archives does not change, which is normally
|
||||
-- the case. But archives may be deleted, and files may be deleted.
|
||||
checkPresentExportWithContentIdentifierM :: BorgRepo -> Key -> ImportLocation -> [ContentIdentifier] -> Annex Bool
|
||||
checkPresentExportWithContentIdentifierM borgrepo k loc cids = prompt $ liftIO $ do
|
||||
checkPresentExportWithContentIdentifierM borgrepo _ loc _ = prompt $ liftIO $ do
|
||||
let p = proc "borg"
|
||||
[ "list"
|
||||
, "--format"
|
||||
|
@ -298,3 +293,26 @@ checkPresentExportWithContentIdentifierM borgrepo k loc cids = prompt $ liftIO $
|
|||
( return False -- repo exists, content not in it
|
||||
, giveup $ "Unable to access borg repository " ++ borgrepo
|
||||
)
|
||||
|
||||
retrieveExportWithContentIdentifierM :: BorgRepo -> ImportLocation -> ContentIdentifier -> FilePath -> Annex Key -> MeterUpdate -> Annex Key
|
||||
retrieveExportWithContentIdentifierM borgrepo loc _ dest mkk _ = do
|
||||
showOutput
|
||||
prompt $ withOtherTmp $ \othertmp -> liftIO $ do
|
||||
-- borgrepo could be relative, and borg has to be run
|
||||
-- in the temp directory to get it to write there
|
||||
absborgrepo <- fromRawFilePath <$> absPath (toRawFilePath borgrepo)
|
||||
let p = proc "borg"
|
||||
[ "extract"
|
||||
, borgArchive absborgrepo archivename
|
||||
, fromRawFilePath archivefile
|
||||
]
|
||||
(Nothing, Nothing, Nothing, pid) <- createProcess $ p
|
||||
{ cwd = Just (fromRawFilePath othertmp) }
|
||||
forceSuccessProcess p pid
|
||||
-- Filepaths in borg archives are relative, so it's ok to
|
||||
-- combine with </>
|
||||
moveFile (fromRawFilePath othertmp </> fromRawFilePath archivefile) dest
|
||||
removeDirectoryRecursive (fromRawFilePath othertmp)
|
||||
mkk
|
||||
where
|
||||
(archivename, archivefile) = extractImportLocation loc
|
||||
|
|
5
doc/todo/borg_sync_tree_not_grafted.mdwn
Normal file
5
doc/todo/borg_sync_tree_not_grafted.mdwn
Normal file
|
@ -0,0 +1,5 @@
|
|||
The tree generated by git-annex sync with a borg remote
|
||||
does not seem to get grafted into the git-annex branch, so
|
||||
would be subject to being lost to GC.
|
||||
|
||||
Is this a general problem affecting importtree too?
|
Loading…
Reference in a new issue