} // end of function - LFSBatchPost /// <summary> /// Creates a <see cref="BatchResponseObject"/> object with information for /// each LFS object in the batch request /// </summary> /// <param name="repo"> /// The local cached repository /// </param> /// <param name="reqObj"> /// The LFS batch request object, with information requested by the client /// </param> /// <returns> /// Task generating a <see cref="BatchResponseObject"/>, with information to /// send to the client /// </returns> public BatchResponseObject CreateBatchLFSResponse(ILocalRepository repo, BatchRequestObject reqObj) { // Create our main response object BatchResponseObject retval = new BatchResponseObject(); // Loop through all of the objects in the request object foreach (var obj in reqObj.Objects) { // We will need a list of actions to return LFSActions actions = new LFSActions(); // We will use the file info object to get the file size later var fileInfo = new FileInfo(repo.LFSObjectPath(obj.OID)); #warning Find a way to get the controller's mapping entry point to build a base URL string baseUrl = $"{Request.Scheme}://{Request.Host}/{Request.PathBase}/"; // Right now, we only support a "download" action, so build it out actions.Download = new LFSActions.DownloadAction() { ExpiresAt = null, ExpiresIn = 0, HREF = $"{baseUrl}/{repo.Remote.Server}/{repo.Remote.Owner}/{repo.Remote.Name}/lfs/download/{obj.OID}" }; retval.Objects.Add(new BatchResponseObject.ResponseLFSItem() { Authenticated = true, OID = obj.OID, Size = (int)fileInfo.Length, Actions = actions, Error = null }); } // end of foreach - object in the LFS request objects call return(retval); } // end of function - CreateBatchLFSResponse
public void DefaultsGetSets() { var obj = new BatchResponseObject(); Assert.IsNotNull(obj.Objects); Assert.AreEqual("basic", obj.Transfer); Assert.IsNull((obj.Objects = null)); Assert.AreEqual("advanced", (obj.Transfer = "advanced")); } /* End of Function - DefaultsGetSets */