future-proofing

This commit is contained in:
Joey Hess 2013-12-25 20:04:31 -04:00
parent 72765aa95e
commit 8803e36814
2 changed files with 13 additions and 7 deletions

View file

@ -129,6 +129,7 @@ data Response
| COST_UNKNOWN | COST_UNKNOWN
| INITREMOTE_SUCCESS | INITREMOTE_SUCCESS
| INITREMOTE_FAILURE ErrorMsg | INITREMOTE_FAILURE ErrorMsg
| UNKNOWN_REQUEST
deriving (Show) deriving (Show)
instance Receivable Response where instance Receivable Response where
@ -144,6 +145,7 @@ instance Receivable Response where
parseCommand "COST_UNKNOWN" = parse0 COST_UNKNOWN parseCommand "COST_UNKNOWN" = parse0 COST_UNKNOWN
parseCommand "INITREMOTE-SUCCESS" = parse0 INITREMOTE_SUCCESS parseCommand "INITREMOTE-SUCCESS" = parse0 INITREMOTE_SUCCESS
parseCommand "INITREMOTE-FAILURE" = parse1 INITREMOTE_FAILURE parseCommand "INITREMOTE-FAILURE" = parse1 INITREMOTE_FAILURE
parseCommand "UNKNOWN-REQUEST" = parse0 UNKNOWN_REQUEST
parseCommand _ = parseFail parseCommand _ = parseFail
-- Requests that the external remote can send at any time it's in control. -- Requests that the external remote can send at any time it's in control.

View file

@ -79,6 +79,10 @@ remote can send any messages it likes while handling the requests.
Once the special remote has finished performing the request, it should Once the special remote has finished performing the request, it should
send one of the corresponding replies listed in the next section. send one of the corresponding replies listed in the next section.
More requests may be added over time, so if the special remote sees a
request it does not understand, it should respond with UNKNOWN-REQUEST
and continue running.
* `PREPARE` * `PREPARE`
Tells the special remote it's time to prepare itself to be used. Tells the special remote it's time to prepare itself to be used.
Only run once, at startup, always immediately after the special remote Only run once, at startup, always immediately after the special remote
@ -141,6 +145,8 @@ while it's handling a request.
Indicates the INITREMOTE succeeded and the remote is ready to use. Indicates the INITREMOTE succeeded and the remote is ready to use.
* `INITREMOTE-FAILURE ErrorMsg` * `INITREMOTE-FAILURE ErrorMsg`
Indicates that INITREMOTE failed. Indicates that INITREMOTE failed.
* `UNKNOWN-REQUEST`
Indicates that the special remote does not know how to handle a request.
## special remote messages ## special remote messages
@ -188,12 +194,11 @@ These messages can be sent at any time by either git-annex or the special
remote. remote.
* `ERROR ErrorMsg` * `ERROR ErrorMsg`
Generic error. Can be sent at any time if things get messed up. Generic error. Can be sent at any time if things get too messed up
When possible, use a more specific reply from the list above. to continue. When possible, use a more specific reply from the list above.
It would be a good idea to send this if git-annex sends a command The special remote program should exit after sending this, as
you do not support. The program should exit after sending this, as
git-annex will not talk to it any further. If the program receives git-annex will not talk to it any further. If the program receives
an ERROR, it can try to recover, or exit with its own ERROR. an ERROR from git-annex, it can exit with its own ERROR.
## Simple shell example ## Simple shell example
@ -249,8 +254,7 @@ while read line; do
echo REMOVE-SUCCESS "$key" echo REMOVE-SUCCESS "$key"
;; ;;
*) *)
echo ERROR "unknown command received: $line" echo UNKNOWN-REQUEST
exit 1
;; ;;
esac esac
done done