add exportedtree to info

info: When used with an exporttree remote, includes an "exportedtree" info,
which is the tree last exported to the remote. During an export conflict,
multiple values will be listed.

This commit was sponsored by John Pellman on Patreon.
This commit is contained in:
Joey Hess 2018-12-03 14:15:15 -04:00
parent 3ad7b7927e
commit b8f9dea27d
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 32 additions and 1 deletions

View file

@ -9,6 +9,9 @@ git-annex (7.20181122) UNRELEASED; urgency=medium
be used, set repo version to 7, which it neglected to do before.
* init: When on a crippled filesystem, and the git version is too old
to use an adjusted unlocked branch, fall back to using direct mode.
* info: When used with an exporttree remote, includes an "exportedtree"
info, which is the tree last exported to the remote. During an export
conflict, multiple values will be listed.
-- Joey Hess <id@joeyh.name> Tue, 27 Nov 2018 12:29:27 -0400

View file

@ -18,6 +18,8 @@ import Remote.Helper.Encryptable (isEncrypted)
import Database.Export
import Annex.Export
import Config
import Git.Types (fromRef)
import Logs.Export
import qualified Data.Map as M
import Control.Concurrent.STM
@ -186,8 +188,11 @@ adjustExportable r = case M.lookup "exporttree" (config r) of
, checkPresentCheap = False
, mkUnavailable = return Nothing
, getInfo = do
ts <- map (\t -> ("exportedtree", fromRef t) )
. map exportedTreeish
<$> getExport (uuid r)
is <- getInfo r
return (is++[("export", "yes")])
return (is++[("export", "yes")]++ts)
}
retrieveKeyFileFromExport getexportlocs exportinconflict k _af dest p = unVerified $
if maybe False (isJust . verifyKeyContent) (maybeLookupBackendVariety (keyVariety k))

View file

@ -0,0 +1,23 @@
[[!comment format=mdwn
username="joey"
subject="""comment 5"""
date="2018-12-03T17:53:59Z"
content="""
I wonder if you'd be better off querying `git annex whereis --json`
for public urls and providing those to the users. Several special remotes
provide public urls. (S3 needs a non-default configuration to do it.)
Anyway back to your question, git-annex arranges for the exported tree to
always be available, including across clones of the repository. So you can
get the exported tree, graft another file into it, and export the new tree.
So how to look up the previously exported tree? [[/internals]] documents
how to find it in the export.log, but it seems there ought to be a
command-line interface to query for it. So I've made `git annex info remote`
provide that information, as "exportedtree". Note that in an export
conflict it may have multiple values. You'll want to use --fast with that,
and probably --json.
Let me know if you need something more, or if this todo can be closed with
that.
"""]]