Declare syncData from the start to avoid declaration shadowing

This commit is contained in:
Brendan Abolivier 2018-12-05 17:14:30 +00:00
parent 176f088215
commit b3985abf72
No known key found for this signature in database
GPG key ID: 8EF1500759F70623

View file

@ -45,6 +45,8 @@ func NewRequestPool(db *storage.SyncServerDatabase, n *Notifier, adb *accounts.D
// called in a dedicated goroutine for this request. This function will block the goroutine
// until a response is ready, or it times out.
func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtypes.Device) util.JSONResponse {
var syncData *types.Response
// Extract values from request
logger := util.GetLogger(req.Context())
userID := device.UserID
@ -65,7 +67,7 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
// If this is an initial sync or timeout=0 we return immediately
if syncReq.since == nil || syncReq.timeout == 0 {
syncData, err := rp.currentSyncForUser(*syncReq, currPos)
syncData, err = rp.currentSyncForUser(*syncReq, currPos)
if err != nil {
return httputil.LogThenError(req, err)
}
@ -103,7 +105,7 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
// of calculating the sync only to get timed out before we
// can respond
syncData, err := rp.currentSyncForUser(*syncReq, currPos)
syncData, err = rp.currentSyncForUser(*syncReq, currPos)
if err != nil {
return httputil.LogThenError(req, err)
}