From: Joey Hess Date: Wed, 16 Aug 2023 19:48:09 +0000 (-0400) Subject: implement Unavilable for borg bup ddar directory rsync X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~32^2~88 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=977403d3384996f949fdc81815db5282a853caa5;p=git-annex.git implement Unavilable for borg bup ddar directory rsync Only gcrypt remains to add support for. (Well, possibly also adb?) Sponsored-by: Luke T. Shumaker on Patreon --- diff --git a/CHANGELOG b/CHANGELOG index 2ec2c1983c..5f5d3f034b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ git-annex (10.20230803) UNRELEASED; urgency=medium * Stop bundling curl in the OSX dmg and linux standalone image. * sync, assist, push, pull: Skip more types of remotes when they are not present due to eg being on a drive that is offline. + (directory, borg, bup, ddar, rsync) * info: Added available to the info displayed for a remote. * Added AVAILABILITY UNAVAILABLE and the UNAVAILABLERESPONSE extension to the external special remote protocol. diff --git a/Remote/Borg.hs b/Remote/Borg.hs index ba22c8cf59..bdd9520603 100644 --- a/Remote/Borg.hs +++ b/Remote/Borg.hs @@ -1,6 +1,6 @@ {- Using borg as a remote. - - - Copyright 2020,2021 Joey Hess + - Copyright 2020,2023 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -23,6 +23,7 @@ import Annex.Tmp import Annex.SpecialRemote.Config import Remote.Helper.Special import Remote.Helper.ExportImport +import Remote.Helper.Path import Annex.UUID import Types.ProposedAccepted import Utility.Metered @@ -112,8 +113,7 @@ gen r u rc gc rs = do , gitconfig = gc , localpath = borgRepoLocalPath borgrepo , remotetype = remote - , availability = pure $ - if borgLocal borgrepo then LocallyAvailable else GloballyAvailable + , availability = checkAvailability borgrepo , readonly = False , appendonly = False -- When the user sets the appendonly field, they are @@ -161,9 +161,13 @@ absBorgRepo r@(BorgRepo p) borgRepoLocalPath :: BorgRepo -> Maybe FilePath borgRepoLocalPath r@(BorgRepo p) - | borgLocal r && not (null p) = Just p + | borgLocal r = Just p | otherwise = Nothing +checkAvailability :: BorgRepo -> Annex Availability +checkAvailability borgrepo@(BorgRepo r) = + checkPathAvailability (borgLocal borgrepo) r + listImportableContentsM :: UUID -> BorgRepo -> ParsedRemoteConfig -> Annex (Maybe (ImportableContentsChunkable Annex (ContentIdentifier, ByteSize))) listImportableContentsM u borgrepo c = prompt $ do imported <- getImported u diff --git a/Remote/Bup.hs b/Remote/Bup.hs index c754850e22..8535edd02d 100644 --- a/Remote/Bup.hs +++ b/Remote/Bup.hs @@ -32,6 +32,7 @@ import qualified Remote.Helper.Ssh as Ssh import Annex.SpecialRemote.Config import Remote.Helper.Special import Remote.Helper.ExportImport +import Remote.Helper.Path import Utility.Hash import Utility.UserInfo import Annex.UUID @@ -97,8 +98,9 @@ gen r u rc gc rs = do then Just buprepo else Nothing , remotetype = remote - , availability = pure $ - if bupLocal buprepo then LocallyAvailable else GloballyAvailable + , availability = if null buprepo + then pure LocallyAvailable + else checkPathAvailability (bupLocal buprepo) buprepo , readonly = False , appendonly = False , untrustworthy = False diff --git a/Remote/Ddar.hs b/Remote/Ddar.hs index 375920a325..9cc5f4a75e 100644 --- a/Remote/Ddar.hs +++ b/Remote/Ddar.hs @@ -25,6 +25,7 @@ import Config.Cost import Annex.SpecialRemote.Config import Remote.Helper.Special import Remote.Helper.ExportImport +import Remote.Helper.Path import Annex.Ssh import Annex.UUID import Utility.SshHost @@ -98,8 +99,9 @@ gen r u rc gc rs = do then Just $ ddarRepoLocation ddarrepo else Nothing , remotetype = remote - , availability = pure $ - if ddarLocal ddarrepo then LocallyAvailable else GloballyAvailable + , availability = checkPathAvailability + (ddarLocal ddarrepo && not (null $ ddarRepoLocation ddarrepo)) + (ddarRepoLocation ddarrepo) , readonly = False , appendonly = False , untrustworthy = False diff --git a/Remote/Directory.hs b/Remote/Directory.hs index b030bb2c46..afaf290306 100644 --- a/Remote/Directory.hs +++ b/Remote/Directory.hs @@ -34,6 +34,7 @@ import Config import Annex.SpecialRemote.Config import Remote.Helper.Special import Remote.Helper.ExportImport +import Remote.Helper.Path import Types.Import import qualified Remote.Directory.LegacyChunked as Legacy import Annex.CopyFile @@ -134,7 +135,7 @@ gen r u rc gc rs = do , readonly = False , appendonly = False , untrustworthy = False - , availability = pure LocallyAvailable + , availability = checkPathAvailability True dir' , remotetype = remote , mkUnavailable = gen r u rc (gc { remoteAnnexDirectory = Just "/dev/null" }) rs diff --git a/Remote/Helper/Git.hs b/Remote/Helper/Git.hs index 70a111e27b..8df181297f 100644 --- a/Remote/Helper/Git.hs +++ b/Remote/Helper/Git.hs @@ -21,7 +21,7 @@ repoCheap = not . Git.repoIsUrl localpathCalc :: Git.Repo -> Maybe FilePath localpathCalc r - | availabilityCalc r == GloballyAvailable = Nothing + | not (Git.repoIsLocal r) && not (Git.repoIsLocalUnknown r) = Nothing | otherwise = Just $ fromRawFilePath $ Git.repoPath r availabilityCalc :: Git.Repo -> Availability diff --git a/Remote/Helper/Path.hs b/Remote/Helper/Path.hs new file mode 100644 index 0000000000..fef6b486f7 --- /dev/null +++ b/Remote/Helper/Path.hs @@ -0,0 +1,19 @@ +{- Utilities for remotes located in a path in the filesystem. + - + - Copyright 2023 Joey Hess + - + - Licensed under the GNU AGPL version 3 or higher. + -} + +module Remote.Helper.Path where + +import Annex.Common +import Types.Availability + +checkPathAvailability :: Bool -> FilePath -> Annex Availability +checkPathAvailability islocal d + | not islocal = return GloballyAvailable + | otherwise = ifM (liftIO $ doesDirectoryExist d) + ( return LocallyAvailable + , return Unavailable + ) diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs index b0fceeab24..aaf0848b86 100644 --- a/Remote/Rsync.hs +++ b/Remote/Rsync.hs @@ -31,6 +31,7 @@ import Annex.Ssh import Annex.Perms import Remote.Helper.Special import Remote.Helper.ExportImport +import Remote.Helper.Path import Types.Export import Types.ProposedAccepted import Remote.Rsync.RsyncUrl @@ -120,8 +121,7 @@ gen r u rc gc rs = do , readonly = False , appendonly = False , untrustworthy = False - , availability = pure $ - if islocal then LocallyAvailable else GloballyAvailable + , availability = checkPathAvailability islocal (rsyncUrl o) , remotetype = remote , mkUnavailable = return Nothing , getInfo = return [("url", url)] diff --git a/git-annex.cabal b/git-annex.cabal index 68c456a849..056503ca55 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -986,6 +986,7 @@ Executable git-annex Remote.Helper.Http Remote.Helper.Messages Remote.Helper.P2P + Remote.Helper.Path Remote.Helper.ReadOnly Remote.Helper.ThirdPartyPopulated Remote.Helper.Special