From 46e14265413327609a2b510f38f4020287e99d1a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 28 Mar 2023 17:00:08 -0400 Subject: [PATCH] external protocol VERSION 2 Support VERSION 2 in the external special remote protocol, which is identical to VERSION 1, but avoids external remote programs neededing to work around the above bug. External remote program that support exporttree=yes are recommended to be updated to send VERSION 2. Sponsored-by: Kevin Mueller on Patreon --- Remote/External/Types.hs | 2 +- doc/design/external_special_remote_protocol.mdwn | 16 ++++++++++++++-- doc/special_remotes/external/example.sh | 2 +- .../external/git-annex-remote-ipfs | 2 +- .../external/git-annex-remote-torrent | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Remote/External/Types.hs b/Remote/External/Types.hs index a12a0d70eb..512913ba8a 100644 --- a/Remote/External/Types.hs +++ b/Remote/External/Types.hs @@ -415,7 +415,7 @@ newtype JobId = JobId Integer deriving (Eq, Ord, Show) supportedProtocolVersions :: [ProtocolVersion] -supportedProtocolVersions = [1] +supportedProtocolVersions = [1, 2] instance Proto.Serializable JobId where serialize (JobId n) = show n diff --git a/doc/design/external_special_remote_protocol.mdwn b/doc/design/external_special_remote_protocol.mdwn index 3d2f0588ae..d4bf6bcf3d 100644 --- a/doc/design/external_special_remote_protocol.mdwn +++ b/doc/design/external_special_remote_protocol.mdwn @@ -39,7 +39,7 @@ empty, but the separating spaces are still required in that case. The special remote is responsible for sending the first message, indicating the version of the protocol it is using. - VERSION 1 + VERSION 2 Recent versions of git-annex respond with a message indicating protocol extensions that it supports. Older versions of @@ -271,7 +271,7 @@ These messages may be sent by the special remote at any time that it's handling a request. * `VERSION Int` - Supported protocol version. Current version is 1. Must be sent first + Supported protocol version. Current version is 2. Must be sent first thing at startup, as until it sees this git-annex does not know how to talk with the special remote program! (git-annex does not send a reply to this message, but may give up if it @@ -428,6 +428,18 @@ remote. git-annex will not talk to it any further. If the program receives an ERROR from git-annex, it can exit with its own ERROR. +## protocol versions + +Currently git-annex supports `VERSION 1` and `VERSION 2`. +The two protocol versions are actually identical. + +Old versions of git-annex that supported only `VERSION 1` +had a bug in their implementation of the +part of the protocol documented in the [[export_and_import_appendix]]. +The bug could result in ontent being exported to the wrong file. +External special remotes that implement that should use `VERSION 2` to +avoid talking to the buggy old version of git-annex. + ## extensions These protocol extensions are currently supported. diff --git a/doc/special_remotes/external/example.sh b/doc/special_remotes/external/example.sh index cfae74ae25..413065d1e0 100755 --- a/doc/special_remotes/external/example.sh +++ b/doc/special_remotes/external/example.sh @@ -150,7 +150,7 @@ doremove () { } # This has to come first, to get the protocol started. -echo VERSION 1 +echo VERSION 2 while read line; do set -- $line diff --git a/doc/special_remotes/external/git-annex-remote-ipfs b/doc/special_remotes/external/git-annex-remote-ipfs index f255f9bc59..f546a1ae81 100755 --- a/doc/special_remotes/external/git-annex-remote-ipfs +++ b/doc/special_remotes/external/git-annex-remote-ipfs @@ -54,7 +54,7 @@ getaddrs () { } # This has to come first, to get the protocol started. -echo VERSION 1 +echo VERSION 2 while read line; do set -- $line diff --git a/doc/special_remotes/external/git-annex-remote-torrent b/doc/special_remotes/external/git-annex-remote-torrent index a3b2bb8580..f41585b7c2 100755 --- a/doc/special_remotes/external/git-annex-remote-torrent +++ b/doc/special_remotes/external/git-annex-remote-torrent @@ -100,7 +100,7 @@ downloadtorrent () { } # This has to come first, to get the protocol started. -echo VERSION 1 +echo VERSION 2 while read line; do set -- $line -- 2.39.5