public override void ProcessRequestBase(HttpContextBase context) { using (Tracer.Step("RpcService.ReceivePack")) { // Ensure that the target directory does not have a non-Git repository. IRepository repository = _repositoryFactory.GetRepository(); if (repository != null && repository.RepositoryType != RepositoryType.Git) { context.Response.StatusCode = (int)HttpStatusCode.BadRequest; if (context.ApplicationInstance != null) { context.ApplicationInstance.CompleteRequest(); } return; } bool acquired = DeploymentLock.TryLockOperation(() => { context.Response.ContentType = "application/x-git-receive-pack-result"; if (_autoSwapHandler.IsAutoSwapOngoing()) { context.Response.StatusCode = (int)HttpStatusCode.Conflict; context.Response.Write(Resources.Error_AutoSwapDeploymentOngoing); context.ApplicationInstance.CompleteRequest(); return; } string username = null; if (AuthUtility.TryExtractBasicAuthUser(context.Request, out username)) { GitServer.SetDeployer(username); } UpdateNoCacheForResponse(context.Response); // This temporary deployment is for ui purposes only, it will always be deleted via finally. ChangeSet tempChangeSet; using (DeploymentManager.CreateTemporaryDeployment(Resources.ReceivingChanges, out tempChangeSet)) { GitServer.Receive(context.Request.GetInputStream(), context.Response.OutputStream); } // TODO: Currently we do not support auto-swap for git push due to an issue where we already sent the headers at the // beginning of the deployment and cannot flag at this point to make the auto swap (by sending the proper headers). //_autoSwapHandler.HandleAutoSwap(verifyActiveDeploymentIdChanged: true); }, TimeSpan.Zero); if (!acquired) { context.Response.StatusCode = 409; context.ApplicationInstance.CompleteRequest(); } } }
public override void ProcessRequestBase(HttpContextBase context) { using (Tracer.Step("RpcService.ReceivePack")) { // Ensure that the target directory does not have a non-Git repository. IRepository repository = _repositoryFactory.GetRepository(); if (repository != null && repository.RepositoryType != RepositoryType.Git) { context.Response.StatusCode = (int)HttpStatusCode.BadRequest; if (context.ApplicationInstance != null) { context.ApplicationInstance.CompleteRequest(); } return; } bool acquired = DeploymentLock.TryLockOperation(() => { string username = null; if (AuthUtility.TryExtractBasicAuthUser(context.Request, out username)) { GitServer.SetDeployer(username); } UpdateNoCacheForResponse(context.Response); context.Response.ContentType = "application/x-git-receive-pack-result"; // This temporary deployment is for ui purposes only, it will always be deleted via finally. ChangeSet tempChangeSet; using (DeploymentManager.CreateTemporaryDeployment(Resources.ReceivingChanges, out tempChangeSet)) { GitServer.Receive(context.Request.GetInputStream(), context.Response.OutputStream); } }, TimeSpan.Zero); if (!acquired) { context.Response.StatusCode = 409; context.ApplicationInstance.CompleteRequest(); } } }