Пример #1
0
        } // 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
Пример #2
0
        public void DefaultsGetsSets()
        {
            var actions = new LFSActions();

            Assert.IsNull(actions.Download);
            Assert.IsNull(actions.Upload);
            Assert.IsNull(actions.Verify);

            var download = new LFSActions.DownloadAction();
            var upload   = new LFSActions.UploadAction();
            var verify   = new LFSActions.VerifyAction();

            actions.Download = download;
            actions.Upload   = upload;
            actions.Verify   = verify;
            Assert.AreEqual(download, actions.Download);
            Assert.AreEqual(upload, actions.Upload);
            Assert.AreEqual(verify, actions.Verify);
        } /* End of Function - DefaultsGetsSets */