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
This commit is contained in:
parent
67c99a4db7
commit
977403d338
9 changed files with 42 additions and 12 deletions
|
@ -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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{- Using borg as a remote.
|
||||
-
|
||||
- Copyright 2020,2021 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2020,2023 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
19
Remote/Helper/Path.hs
Normal file
19
Remote/Helper/Path.hs
Normal file
|
@ -0,0 +1,19 @@
|
|||
{- Utilities for remotes located in a path in the filesystem.
|
||||
-
|
||||
- Copyright 2023 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- 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
|
||||
)
|
|
@ -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)]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue