directory CoW on export
Completing Cow support for directory.
This commit is contained in:
parent
b86206b553
commit
58da9f74b7
3 changed files with 11 additions and 15 deletions
|
@ -87,7 +87,7 @@ gen r u rc gc rs = do
|
|||
, checkPresent = checkPresentDummy
|
||||
, checkPresentCheap = True
|
||||
, exportActions = ExportActions
|
||||
{ storeExport = storeExportM dir
|
||||
{ storeExport = storeExportM dir cow
|
||||
, retrieveExport = retrieveExportM dir cow
|
||||
, removeExport = removeExportM dir
|
||||
, versionedExport = False
|
||||
|
@ -101,7 +101,7 @@ gen r u rc gc rs = do
|
|||
{ listImportableContents = listImportableContentsM dir
|
||||
, importKey = Just (importKeyM dir)
|
||||
, retrieveExportWithContentIdentifier = retrieveExportWithContentIdentifierM dir cow
|
||||
, storeExportWithContentIdentifier = storeExportWithContentIdentifierM dir
|
||||
, storeExportWithContentIdentifier = storeExportWithContentIdentifierM dir cow
|
||||
, removeExportWithContentIdentifier = removeExportWithContentIdentifierM dir
|
||||
-- Not needed because removeExportWithContentIdentifier
|
||||
-- auto-removes empty directories.
|
||||
|
@ -303,15 +303,15 @@ checkPresentGeneric' d check = ifM check
|
|||
)
|
||||
)
|
||||
|
||||
storeExportM :: RawFilePath -> FilePath -> Key -> ExportLocation -> MeterUpdate -> Annex ()
|
||||
storeExportM d src _k loc p = liftIO $ do
|
||||
createDirectoryUnder d (P.takeDirectory dest)
|
||||
storeExportM :: RawFilePath -> CopyCoWTried -> FilePath -> Key -> ExportLocation -> MeterUpdate -> Annex ()
|
||||
storeExportM d cow src k loc p = do
|
||||
liftIO $ createDirectoryUnder d (P.takeDirectory dest)
|
||||
-- Write via temp file so that checkPresentGeneric will not
|
||||
-- see it until it's fully stored.
|
||||
viaTmp go (fromRawFilePath dest) ()
|
||||
where
|
||||
dest = exportPath d loc
|
||||
go tmp () = withMeteredFile src p (L.writeFile tmp)
|
||||
go tmp () = fileCopierUnVerified cow src tmp k p
|
||||
|
||||
retrieveExportM :: RawFilePath -> CopyCoWTried -> Key -> ExportLocation -> FilePath -> MeterUpdate -> Annex ()
|
||||
retrieveExportM d cow k loc dest p = fileCopierUnVerified cow src dest k p
|
||||
|
@ -491,14 +491,12 @@ retrieveExportWithContentIdentifierM dir cow loc cid dest mkkey p =
|
|||
=<< R.getFileStatus f
|
||||
guardSameContentIdentifiers cont cid currcid
|
||||
|
||||
storeExportWithContentIdentifierM :: RawFilePath -> FilePath -> Key -> ExportLocation -> [ContentIdentifier] -> MeterUpdate -> Annex ContentIdentifier
|
||||
storeExportWithContentIdentifierM dir src _k loc overwritablecids p = do
|
||||
storeExportWithContentIdentifierM :: RawFilePath -> CopyCoWTried -> FilePath -> Key -> ExportLocation -> [ContentIdentifier] -> MeterUpdate -> Annex ContentIdentifier
|
||||
storeExportWithContentIdentifierM dir cow src k loc overwritablecids p = do
|
||||
liftIO $ createDirectoryUnder dir (toRawFilePath destdir)
|
||||
withTmpFileIn destdir template $ \tmpf tmph -> do
|
||||
withTmpFileIn destdir template $ \tmpf _tmph -> do
|
||||
fileCopierUnVerified cow src tmpf k p
|
||||
let tmpf' = toRawFilePath tmpf
|
||||
liftIO $ withMeteredFile src p (L.hPut tmph)
|
||||
liftIO $ hFlush tmph
|
||||
liftIO $ hClose tmph
|
||||
resetAnnexFilePerm tmpf'
|
||||
liftIO (getFileStatus tmpf) >>= liftIO . mkContentIdentifier tmpf' >>= \case
|
||||
Nothing -> giveup "unable to generate content identifier"
|
||||
|
|
|
@ -18,3 +18,4 @@ Joey, is it expected to take advantage of CoW with git-annex 8.20210223-1~ndall+
|
|||
[[!meta author=yoh]]
|
||||
[[!tag projects/datalad]]
|
||||
|
||||
> [[fixed|done]] --[[Joey]]
|
||||
|
|
|
@ -4,7 +4,4 @@
|
|||
date="2021-04-14T19:33:13Z"
|
||||
content="""
|
||||
Implemented CoW for directory special remote, comprehensively.
|
||||
|
||||
(Except for when exporting to it, which I'll do for completeness before closing
|
||||
this.)
|
||||
"""]]
|
||||
|
|
Loading…
Reference in a new issue