no remotes support import yet

This commit is contained in:
Joey Hess 2019-02-20 15:55:01 -04:00
parent e8bfc3640b
commit ccc0684d21
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
20 changed files with 68 additions and 22 deletions

View file

@ -17,7 +17,7 @@ import qualified Git
import Config.Cost
import Remote.Helper.Special
import Remote.Helper.Messages
import Remote.Helper.Export
import Remote.Helper.ExportImport
import Annex.UUID
import Utility.Metered
@ -35,6 +35,7 @@ remote = RemoteType
, generate = gen
, setup = adbSetup
, exportSupported = exportIsSupported
, importSupported = importUnsupported
}
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@ -61,6 +62,7 @@ gen r u c gc = do
, removeExportDirectory = Just $ removeExportDirectoryM serial adir
, renameExport = renameExportM serial adir
}
, importActions = importUnsupported
, whereisKey = Nothing
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -27,7 +27,7 @@ import Annex.Perms
import Annex.Tmp
import Annex.UUID
import qualified Annex.Url as Url
import Remote.Helper.Export
import Remote.Helper.ExportImport
import Network.URI
@ -43,6 +43,7 @@ remote = RemoteType
, generate = gen
, setup = error "not supported"
, exportSupported = exportUnsupported
, importSupported = importUnsupported
}
-- There is only one bittorrent remote, and it always exists.
@ -68,6 +69,7 @@ gen r _ c gc = do
, checkPresent = checkKey
, checkPresentCheap = False
, exportActions = exportUnsupported
, importActions = importUnsupported
, whereisKey = Nothing
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -25,7 +25,7 @@ import Config.Cost
import qualified Remote.Helper.Ssh as Ssh
import Remote.Helper.Special
import Remote.Helper.Messages
import Remote.Helper.Export
import Remote.Helper.ExportImport
import Utility.Hash
import Utility.UserInfo
import Annex.UUID
@ -41,6 +41,7 @@ remote = RemoteType
, generate = gen
, setup = bupSetup
, exportSupported = exportUnsupported
, importSupported = importUnsupported
}
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@ -67,6 +68,7 @@ gen r u c gc = do
, checkPresent = checkPresentDummy
, checkPresentCheap = bupLocal buprepo
, exportActions = exportUnsupported
, importActions = importUnsupported
, whereisKey = Nothing
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -19,7 +19,7 @@ import qualified Git
import Config
import Config.Cost
import Remote.Helper.Special
import Remote.Helper.Export
import Remote.Helper.ExportImport
import Annex.Ssh
import Annex.UUID
import Utility.SshHost
@ -36,6 +36,7 @@ remote = RemoteType
, generate = gen
, setup = ddarSetup
, exportSupported = exportUnsupported
, importSupported = importUnsupported
}
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@ -66,6 +67,7 @@ gen r u c gc = do
, checkPresent = checkPresentDummy
, checkPresentCheap = ddarLocal ddarrepo
, exportActions = exportUnsupported
, importActions = importUnsupported
, whereisKey = Nothing
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -26,7 +26,7 @@ import Config.Cost
import Config
import Utility.FileMode
import Remote.Helper.Special
import Remote.Helper.Export
import Remote.Helper.ExportImport
import qualified Remote.Directory.LegacyChunked as Legacy
import Annex.Content
import Annex.UUID
@ -40,6 +40,7 @@ remote = RemoteType
, generate = gen
, setup = directorySetup
, exportSupported = exportIsSupported
, importSupported = importUnsupported
}
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@ -73,6 +74,7 @@ gen r u c gc = do
, removeExportDirectory = Nothing
, renameExport = renameExportM dir
}
, importActions = importUnsupported
, whereisKey = Nothing
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -19,7 +19,7 @@ import Config
import Git.Config (isTrue, boolConfig)
import Git.Env
import Remote.Helper.Special
import Remote.Helper.Export
import Remote.Helper.ExportImport
import Annex.Export
import Remote.Helper.ReadOnly
import Remote.Helper.Messages
@ -48,6 +48,7 @@ remote = RemoteType
, generate = gen
, setup = externalSetup
, exportSupported = checkExportSupported
, importSupported = importUnsupported
}
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@ -119,6 +120,7 @@ gen r u c gc
, checkPresent = checkPresentDummy
, checkPresentCheap = False
, exportActions = exportactions
, importActions = importUnsupported
, whereisKey = towhereis
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -38,7 +38,7 @@ import Remote.Helper.Git
import Remote.Helper.Encryptable
import Remote.Helper.Special
import Remote.Helper.Messages
import Remote.Helper.Export
import Remote.Helper.ExportImport
import qualified Remote.Helper.Ssh as Ssh
import Utility.Metered
import Annex.UUID
@ -61,6 +61,7 @@ remote = RemoteType
, generate = gen
, setup = gCryptSetup
, exportSupported = exportUnsupported
, importSupported = importUnsupported
}
chainGen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@ -119,6 +120,7 @@ gen' r u c gc = do
, checkPresent = checkPresentDummy
, checkPresentCheap = repoCheap r
, exportActions = exportUnsupported
, importActions = importUnsupported
, whereisKey = Nothing
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -48,7 +48,7 @@ import Utility.Batch
import Utility.SimpleProtocol
import Remote.Helper.Git
import Remote.Helper.Messages
import Remote.Helper.Export
import Remote.Helper.ExportImport
import qualified Remote.Helper.Ssh as Ssh
import qualified Remote.GCrypt
import qualified Remote.P2P
@ -72,6 +72,7 @@ remote = RemoteType
, generate = gen
, setup = gitSetup
, exportSupported = exportUnsupported
, importSupported = importUnsupported
}
list :: Bool -> Annex [Git.Repo]
@ -165,6 +166,7 @@ gen r u c gc
, checkPresent = inAnnex new st
, checkPresentCheap = repoCheap r
, exportActions = exportUnsupported
, importActions = importUnsupported
, whereisKey = Nothing
, remoteFsck = if Git.repoIsUrl r
then Nothing

View file

@ -18,7 +18,7 @@ import Config
import Config.Cost
import Remote.Helper.Special
import Remote.Helper.Messages
import Remote.Helper.Export
import Remote.Helper.ExportImport
import qualified Remote.Helper.AWS as AWS
import Creds
import Utility.Metered
@ -36,6 +36,7 @@ remote = RemoteType
, generate = gen
, setup = glacierSetup
, exportSupported = exportUnsupported
, importSupported = importUnsupported
}
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@ -65,6 +66,7 @@ gen r u c gc = new <$> remoteCost gc veryExpensiveRemoteCost
, checkPresent = checkPresentDummy
, checkPresentCheap = False
, exportActions = exportUnsupported
, importActions = importUnsupported
, whereisKey = Nothing
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -1,13 +1,13 @@
{- exports to remotes
{- Helper to make remotes support export and import (or not).
-
- Copyright 2017 Joey Hess <id@joeyh.name>
- Copyright 2017-2019 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
{-# LANGUAGE FlexibleInstances #-}
module Remote.Helper.Export where
module Remote.Helper.ExportImport where
import Annex.Common
import Types.Remote
@ -43,6 +43,20 @@ instance HasExportUnsupported (ExportActions Annex) where
, renameExport = \_ _ _ -> return False
}
-- | Use for remotes that do not support imports.
class HasImportUnsupported a where
importUnsupported :: a
instance HasImportUnsupported (RemoteConfig -> RemoteGitConfig -> Annex Bool) where
importUnsupported = \_ _ -> return False
instance HasImportUnsupported (ImportActions Annex) where
importUnsupported = ImportActions
{ listContents = return Nothing
, retrieveExportWithContentIdentifier = \_ _ _ _ -> return Nothing
, storeExportWithContentIdentifier = \_ _ _ _ _ -> return Nothing
}
exportIsSupported :: RemoteConfig -> RemoteGitConfig -> Annex Bool
exportIsSupported = \_ _ -> return True

View file

@ -16,7 +16,7 @@ import Config.Cost
import Annex.UUID
import Remote.Helper.Special
import Remote.Helper.Messages
import Remote.Helper.Export
import Remote.Helper.ExportImport
import Utility.Env
import Messages.Progress
@ -32,6 +32,7 @@ remote = RemoteType
, generate = gen
, setup = hookSetup
, exportSupported = exportUnsupported
, importSupported = importUnsupported
}
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@ -57,6 +58,7 @@ gen r u c gc = do
, checkPresent = checkPresentDummy
, checkPresentCheap = False
, exportActions = exportUnsupported
, importActions = importUnsupported
, whereisKey = Nothing
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -18,7 +18,7 @@ import Types.Remote
import Annex.UUID
import Remote.Helper.Hooks
import Remote.Helper.ReadOnly
import Remote.Helper.Export
import Remote.Helper.ExportImport
import qualified Git
import qualified Git.Config

View file

@ -23,7 +23,7 @@ import Annex.UUID
import Config
import Config.Cost
import Remote.Helper.Git
import Remote.Helper.Export
import Remote.Helper.ExportImport
import Remote.Helper.P2P
import Utility.AuthToken
@ -38,6 +38,7 @@ remote = RemoteType
, generate = \_ _ _ _ -> return Nothing
, setup = error "P2P remotes are set up using git-annex p2p"
, exportSupported = exportUnsupported
, importSupported = importUnsupported
}
chainGen :: P2PAddress -> Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@ -59,6 +60,7 @@ chainGen addr r u c gc = do
, checkPresent = checkpresent protorunner
, checkPresentCheap = False
, exportActions = exportUnsupported
, importActions = importUnsupported
, whereisKey = Nothing
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -28,7 +28,7 @@ import Annex.UUID
import Annex.Ssh
import Remote.Helper.Special
import Remote.Helper.Messages
import Remote.Helper.Export
import Remote.Helper.ExportImport
import Types.Export
import Remote.Rsync.RsyncUrl
import Crypto
@ -51,6 +51,7 @@ remote = RemoteType
, generate = gen
, setup = rsyncSetup
, exportSupported = exportIsSupported
, importSupported = importUnsupported
}
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@ -85,6 +86,7 @@ gen r u c gc = do
, removeExportDirectory = Just (removeExportDirectoryM o)
, renameExport = renameExportM o
}
, importActions = importUnsupported
, whereisKey = Nothing
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -46,7 +46,7 @@ import Config.Cost
import Remote.Helper.Special
import Remote.Helper.Http
import Remote.Helper.Messages
import Remote.Helper.Export
import Remote.Helper.ExportImport
import qualified Remote.Helper.AWS as AWS
import Creds
import Annex.UUID
@ -72,6 +72,7 @@ remote = RemoteType
, generate = gen
, setup = s3Setup
, exportSupported = exportIsSupported
, importSupported = importUnsupported
}
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@ -112,6 +113,7 @@ gen r u c gc = do
, removeExportDirectory = Nothing
, renameExport = renameExportS3 hdl this info
}
, importActions = importUnsupported
, whereisKey = Just (getPublicWebUrls u info c)
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -34,7 +34,7 @@ import qualified Git
import Config
import Config.Cost
import Remote.Helper.Special
import Remote.Helper.Export
import Remote.Helper.ExportImport
import Annex.UUID
import Annex.Content
import Logs.RemoteState
@ -58,6 +58,7 @@ remote = RemoteType
, generate = gen
, setup = tahoeSetup
, exportSupported = exportUnsupported
, importSupported = importUnsupported
}
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@ -80,6 +81,7 @@ gen r u c gc = do
, checkPresent = checkKey u hdl
, checkPresentCheap = False
, exportActions = exportUnsupported
, importActions = importUnsupported
, whereisKey = Just (getWhereisKey u)
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -10,7 +10,7 @@ module Remote.Web (remote, getWebUrls) where
import Annex.Common
import Types.Remote
import Remote.Helper.Messages
import Remote.Helper.Export
import Remote.Helper.ExportImport
import qualified Git
import qualified Git.Construct
import Annex.Content
@ -29,6 +29,7 @@ remote = RemoteType
, generate = gen
, setup = error "not supported"
, exportSupported = exportUnsupported
, importSupported = importUnsupported
}
-- There is only one web remote, and it always exists.
@ -57,6 +58,7 @@ gen r _ c gc = do
, checkPresent = checkKey
, checkPresentCheap = False
, exportActions = exportUnsupported
, importActions = importUnsupported
, whereisKey = Nothing
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -34,7 +34,7 @@ import Config.Cost
import Remote.Helper.Special
import Remote.Helper.Messages
import Remote.Helper.Http
import Remote.Helper.Export
import Remote.Helper.ExportImport
import qualified Remote.Helper.Chunked.Legacy as Legacy
import Creds
import Utility.Metered
@ -53,6 +53,7 @@ remote = RemoteType
, generate = gen
, setup = webdavSetup
, exportSupported = exportIsSupported
, importSupported = importUnsupported
}
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@ -88,6 +89,7 @@ gen r u c gc = new <$> remoteCost gc expensiveRemoteCost
removeExportDirectoryDav this
, renameExport = renameExportDav this
}
, importActions = importUnsupported
, whereisKey = Nothing
, remoteFsck = Nothing
, repairRepo = Nothing

View file

@ -263,7 +263,7 @@ data ImportActions a = ImportActions
--
-- May also find old versions of files that are still stored in the
-- remote, and return a ContentHistory with multiple nodes.
{ listContents :: a (ContentHistory [(ExportLocation, ContentIdentifier)])
{ listContents :: a (Maybe (ContentHistory [(ExportLocation, ContentIdentifier)]))
-- Retrieves a file from the remote. Ensures that the file
-- it retrieves has the requested ContentIdentifier.
--

View file

@ -929,7 +929,7 @@ Executable git-annex
Remote.Helper.Chunked
Remote.Helper.Chunked.Legacy
Remote.Helper.Encryptable
Remote.Helper.Export
Remote.Helper.ExportImport
Remote.Helper.Git
Remote.Helper.Hooks
Remote.Helper.Messages