Move getting master key and manifest into ensure_connected
This commit is contained in:
parent
f74bd695d2
commit
12cd4c92d6
1 changed files with 17 additions and 2 deletions
|
@ -24,6 +24,7 @@ sha1()
|
||||||
|
|
||||||
LOCALDIR="${GIT_DIR:-.git}/remote-gcrypt"
|
LOCALDIR="${GIT_DIR:-.git}/remote-gcrypt"
|
||||||
DUMMYKEY="00000000000000000000"
|
DUMMYKEY="00000000000000000000"
|
||||||
|
DID_CONNECT=
|
||||||
|
|
||||||
isurl() { test -z "${2%%$1://*}" ; }
|
isurl() { test -z "${2%%$1://*}" ; }
|
||||||
|
|
||||||
|
@ -122,6 +123,17 @@ make_new_repo()
|
||||||
printf "%s" "$MASTERKEY" | gpg -e $RECIPIENTS | PUT "$URL" masterkey
|
printf "%s" "$MASTERKEY" | gpg -e $RECIPIENTS | PUT "$URL" masterkey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ensure_connected()
|
||||||
|
{
|
||||||
|
if [ ! -z "$DID_CONNECT" ]
|
||||||
|
then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
DID_CONNECT=1
|
||||||
|
MASTERKEY="$(get_masterkey)"
|
||||||
|
MANIFESTDATA="$(GET_OR_EMPTY "$URL" manifest | DECRYPT)"
|
||||||
|
}
|
||||||
|
|
||||||
get_masterkey()
|
get_masterkey()
|
||||||
{
|
{
|
||||||
(GET "$URL" masterkey 2>/dev/null || : ) | \
|
(GET "$URL" masterkey 2>/dev/null || : ) | \
|
||||||
|
@ -139,6 +151,8 @@ do_list()
|
||||||
{
|
{
|
||||||
local OBJID
|
local OBJID
|
||||||
local REFNAME
|
local REFNAME
|
||||||
|
ensure_connected
|
||||||
|
|
||||||
printf "%s\n" "$MANIFESTDATA" | while read LINE
|
printf "%s\n" "$MANIFESTDATA" | while read LINE
|
||||||
do
|
do
|
||||||
OBJID=${LINE%% *}
|
OBJID=${LINE%% *}
|
||||||
|
@ -164,6 +178,8 @@ do_fetch()
|
||||||
local PREMOTE
|
local PREMOTE
|
||||||
local PBOTH
|
local PBOTH
|
||||||
local PHAVE
|
local PHAVE
|
||||||
|
ensure_connected
|
||||||
|
|
||||||
touch "$LOCALDIR/packfest"
|
touch "$LOCALDIR/packfest"
|
||||||
PREMOTE="$(GET_OR_EMPTY "$URL" packfest | DECRYPT)"
|
PREMOTE="$(GET_OR_EMPTY "$URL" packfest | DECRYPT)"
|
||||||
if [ -z "$PREMOTE" ]
|
if [ -z "$PREMOTE" ]
|
||||||
|
@ -211,6 +227,7 @@ do_push()
|
||||||
local PACKFEST
|
local PACKFEST
|
||||||
local prefix_
|
local prefix_
|
||||||
local suffix_
|
local suffix_
|
||||||
|
ensure_connected
|
||||||
|
|
||||||
if [ "$MASTERKEY" = "$DUMMYKEY" ]
|
if [ "$MASTERKEY" = "$DUMMYKEY" ]
|
||||||
then
|
then
|
||||||
|
@ -292,8 +309,6 @@ URL=$2
|
||||||
{ echo_info "Supported URLs: Absolute path, sftp://, ssh://" ; exit 1 ; }
|
{ echo_info "Supported URLs: Absolute path, sftp://, ssh://" ; exit 1 ; }
|
||||||
|
|
||||||
mkdir -p "$LOCALDIR"
|
mkdir -p "$LOCALDIR"
|
||||||
MASTERKEY="$(get_masterkey)"
|
|
||||||
MANIFESTDATA="$(GET_OR_EMPTY "$URL" manifest | DECRYPT)"
|
|
||||||
|
|
||||||
while read INPUT
|
while read INPUT
|
||||||
do
|
do
|
||||||
|
|
Loading…
Reference in a new issue