support removing objects from borg

This commit is contained in:
Joey Hess 2020-12-28 16:36:52 -04:00
parent bfdaee234f
commit 69d4b84501
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -98,7 +98,7 @@ gen r u rc gc rs = do
-- actions will never be used. -- actions will never be used.
, storeExportWithContentIdentifier = storeExportWithContentIdentifier importUnsupported , storeExportWithContentIdentifier = storeExportWithContentIdentifier importUnsupported
, removeExportDirectoryWhenEmpty = removeExportDirectoryWhenEmpty importUnsupported , removeExportDirectoryWhenEmpty = removeExportDirectoryWhenEmpty importUnsupported
, removeExportWithContentIdentifier = removeExportWithContentIdentifier importUnsupported , removeExportWithContentIdentifier = removeExportWithContentIdentifierM borgrepo
} }
, whereisKey = Nothing , whereisKey = Nothing
, remoteFsck = Nothing , remoteFsck = Nothing
@ -343,3 +343,16 @@ retrieveExportWithContentIdentifierM borgrepo loc _ dest mkk _ = do
mkk mkk
where where
(archivename, archivefile) = extractImportLocation loc (archivename, archivefile) = extractImportLocation loc
removeExportWithContentIdentifierM :: BorgRepo -> Key -> ImportLocation -> [ContentIdentifier] -> Annex ()
removeExportWithContentIdentifierM borgrepo _ loc _ = do
ok <- liftIO $ boolSystem "borg"
[ Param "recreate"
, Param (borgArchive borgrepo archivename)
, Param "--exclude"
, File (fromRawFilePath archivefile)
]
unless ok $
giveup "borg failed to remove the file"
where
(archivename, archivefile) = extractImportLocation loc