Issue #259: Address CR comments

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
This commit is contained in:
Hector Sanjuan 2017-12-04 13:59:48 +01:00
parent 4922c95589
commit d6a7caf7a4
4 changed files with 18 additions and 19 deletions

View File

@ -1,2 +1 @@
Dockerfile Dockerfile*
Dockerfile-*

View File

@ -378,22 +378,22 @@ func (api *API) peerRemoveHandler(w http.ResponseWriter, r *http.Request) {
} }
func (api *API) pinHandler(w http.ResponseWriter, r *http.Request) { func (api *API) pinHandler(w http.ResponseWriter, r *http.Request) {
if c := parseCidOrError(w, r); c.Cid != "" { if ps := parseCidOrError(w, r); ps.Cid != "" {
err := api.rpcClient.Call("", err := api.rpcClient.Call("",
"Cluster", "Cluster",
"Pin", "Pin",
c, ps,
&struct{}{}) &struct{}{})
sendAcceptedResponse(w, err) sendAcceptedResponse(w, err)
} }
} }
func (api *API) unpinHandler(w http.ResponseWriter, r *http.Request) { func (api *API) unpinHandler(w http.ResponseWriter, r *http.Request) {
if c := parseCidOrError(w, r); c.Cid != "" { if ps := parseCidOrError(w, r); ps.Cid != "" {
err := api.rpcClient.Call("", err := api.rpcClient.Call("",
"Cluster", "Cluster",
"Unpin", "Unpin",
c, ps,
&struct{}{}) &struct{}{})
sendAcceptedResponse(w, err) sendAcceptedResponse(w, err)
} }
@ -410,12 +410,12 @@ func (api *API) allocationsHandler(w http.ResponseWriter, r *http.Request) {
} }
func (api *API) allocationHandler(w http.ResponseWriter, r *http.Request) { func (api *API) allocationHandler(w http.ResponseWriter, r *http.Request) {
if c := parseCidOrError(w, r); c.Cid != "" { if ps := parseCidOrError(w, r); ps.Cid != "" {
var pin types.PinSerial var pin types.PinSerial
err := api.rpcClient.Call("", err := api.rpcClient.Call("",
"Cluster", "Cluster",
"PinGet", "PinGet",
c, ps,
&pin) &pin)
if err != nil { // errors here are 404s if err != nil { // errors here are 404s
sendErrorResponse(w, 404, err.Error()) sendErrorResponse(w, 404, err.Error())
@ -452,13 +452,13 @@ func (api *API) statusHandler(w http.ResponseWriter, r *http.Request) {
queryValues := r.URL.Query() queryValues := r.URL.Query()
local := queryValues.Get("local") local := queryValues.Get("local")
if c := parseCidOrError(w, r); c.Cid != "" { if ps := parseCidOrError(w, r); ps.Cid != "" {
if local == "true" { if local == "true" {
var pinInfo types.PinInfoSerial var pinInfo types.PinInfoSerial
err := api.rpcClient.Call("", err := api.rpcClient.Call("",
"Cluster", "Cluster",
"StatusLocal", "StatusLocal",
c, ps,
&pinInfo) &pinInfo)
sendResponse(w, err, pinInfoToGlobal(pinInfo)) sendResponse(w, err, pinInfoToGlobal(pinInfo))
} else { } else {
@ -466,7 +466,7 @@ func (api *API) statusHandler(w http.ResponseWriter, r *http.Request) {
err := api.rpcClient.Call("", err := api.rpcClient.Call("",
"Cluster", "Cluster",
"Status", "Status",
c, ps,
&pinInfo) &pinInfo)
sendResponse(w, err, pinInfo) sendResponse(w, err, pinInfo)
} }
@ -500,13 +500,13 @@ func (api *API) syncHandler(w http.ResponseWriter, r *http.Request) {
queryValues := r.URL.Query() queryValues := r.URL.Query()
local := queryValues.Get("local") local := queryValues.Get("local")
if c := parseCidOrError(w, r); c.Cid != "" { if ps := parseCidOrError(w, r); ps.Cid != "" {
if local == "true" { if local == "true" {
var pinInfo types.PinInfoSerial var pinInfo types.PinInfoSerial
err := api.rpcClient.Call("", err := api.rpcClient.Call("",
"Cluster", "Cluster",
"SyncLocal", "SyncLocal",
c, ps,
&pinInfo) &pinInfo)
sendResponse(w, err, pinInfoToGlobal(pinInfo)) sendResponse(w, err, pinInfoToGlobal(pinInfo))
} else { } else {
@ -514,7 +514,7 @@ func (api *API) syncHandler(w http.ResponseWriter, r *http.Request) {
err := api.rpcClient.Call("", err := api.rpcClient.Call("",
"Cluster", "Cluster",
"Sync", "Sync",
c, ps,
&pinInfo) &pinInfo)
sendResponse(w, err, pinInfo) sendResponse(w, err, pinInfo)
} }
@ -541,13 +541,13 @@ func (api *API) recoverHandler(w http.ResponseWriter, r *http.Request) {
queryValues := r.URL.Query() queryValues := r.URL.Query()
local := queryValues.Get("local") local := queryValues.Get("local")
if c := parseCidOrError(w, r); c.Cid != "" { if ps := parseCidOrError(w, r); ps.Cid != "" {
if local == "true" { if local == "true" {
var pinInfo types.PinInfoSerial var pinInfo types.PinInfoSerial
err := api.rpcClient.Call("", err := api.rpcClient.Call("",
"Cluster", "Cluster",
"RecoverLocal", "RecoverLocal",
c, ps,
&pinInfo) &pinInfo)
sendResponse(w, err, pinInfoToGlobal(pinInfo)) sendResponse(w, err, pinInfoToGlobal(pinInfo))
} else { } else {
@ -555,7 +555,7 @@ func (api *API) recoverHandler(w http.ResponseWriter, r *http.Request) {
err := api.rpcClient.Call("", err := api.rpcClient.Call("",
"Cluster", "Cluster",
"Recover", "Recover",
c, ps,
&pinInfo) &pinInfo)
sendResponse(w, err, pinInfo) sendResponse(w, err, pinInfo)
} }

View File

@ -883,7 +883,7 @@ func (c *Cluster) SyncAllLocal() ([]api.PinInfo, error) {
return syncedItems, err return syncedItems, err
} }
// Sync triggers a LocalSyncCid() operation for a given Cid // Sync triggers a SyncLocal() operation for a given Cid.
// in all cluster peers. // in all cluster peers.
func (c *Cluster) Sync(h *cid.Cid) (api.GlobalPinInfo, error) { func (c *Cluster) Sync(h *cid.Cid) (api.GlobalPinInfo, error) {
return c.globalPinInfoCid("SyncLocal", h) return c.globalPinInfoCid("SyncLocal", h)

View File

@ -402,7 +402,7 @@ error state, usually because the IPFS pin or unpin operation has failed.
The command will wait for any operations to succeed and will return the status The command will wait for any operations to succeed and will return the status
of the item upon completion. Note that, when running on the full sets of tracked of the item upon completion. Note that, when running on the full sets of tracked
CIDs (without argument), it may take considerable long time. CIDs (without argument), it may take a considerably long time.
When the --local flag is passed, it will only trigger recover When the --local flag is passed, it will only trigger recover
operations on the contacted peer (as opposed to on every peer). operations on the contacted peer (as opposed to on every peer).