🛰️航天仿真算法库 SpaceAST 0.3.1
载入中...
搜索中...
未找到
Network

详细描述

类

struct  ast::LfsPointerInfo
 
class  ast::NetworkStreamReceiver
 
class  ast::CollectingStreamReceiver
 
class  ast::FileDownloadReceiver
 

类型定义

using ast::DownloadProgressCallback = std::function<bool(uint64_t downloaded, uint64_t total)>
 

函数

errc_t ast::aLfsParsePointer (StringView pointerText, LfsPointerInfo &info)
 
std::string ast::aLfsEndpoint (StringView remoteUrl)
 
std::string ast::aLfsBatchRequestBody (StringView oid, std::size_t size)
 
errc_t ast::aDownloadLfs (StringView pointerFile, StringView outputFile, StringView remoteUrl)
 

类型定义说明

◆ DownloadProgressCallback

using ast::DownloadProgressCallback = std::function<bool(uint64_t downloaded, uint64_t total)>

下载进度回调:downloaded 为已下载字节数;total 为总字节数,为 0 表示未知

返回
true 继续下载;false 中止下载(aDownloadFile 将返回 eErrorCancelled)

函数说明

◆ aDownloadLfs()

AST_UTIL_CAPI errc_t ast::aDownloadLfs ( StringView pointerFile,
StringView outputFile,
StringView remoteUrl )

下载 Git LFS 对象到本地文件

发送 POST batch 请求换取带签名的下载地址,再 GET 下载。 对象先写入 outputFile+".part",成功后才重命名为 outputFile, 任何失败都会清理临时文件,避免在目标路径残留截断/伪冒文件。

参数
pointerFile指针文件路径
outputFile目标文件路径
remoteUrlgit 远端地址(如 https://github.com/<owner>/<repo>.git)
返回
eNoError 表示下载成功

◆ aLfsBatchRequestBody()

AST_UTIL_API std::string ast::aLfsBatchRequestBody ( StringView oid,
std::size_t size )

构建 Git LFS batch download 请求体

生成形如 {"operation":"download","transfers":["basic"], "objects":[{"oid":..,"size":..}]} 的 JSON 文本。

参数
oid对象 sha256 十六进制
size对象字节数
返回
请求体 JSON 文本

◆ aLfsEndpoint()

AST_UTIL_API std::string ast::aLfsEndpoint ( StringView remoteUrl)

从 git 远端地址推导 LFS 批量端点

规则为「远端地址 + /info/lfs」,并【保留 .git 后缀】。 https://github.com/<owner>/<repo>.git -> https://github.com/<owner>/<repo>.git/info/lfs

注解
GitHub 的 LFS 端点必须保留 .git,去掉会返回 422。
参数
remoteUrlgit 远端地址
返回
LFS 批量端点

◆ aLfsParsePointer()

AST_UTIL_API errc_t ast::aLfsParsePointer ( StringView pointerText,
LfsPointerInfo & info )

解析 Git LFS 指针文本

指针是形如下面几行的纯文本,不含任何下载地址,只有对象指纹: version https://git-lfs.github.com/spec/v1 oid sha256:06b7... <- 对象内容的 sha256 十六进制 size 61440 <- 对象字节数

参数
pointerText指针文本(可直接取文件内容)
info输出解析结果;缺 oid 时报错并保持 info 为空
返回
eNoError 成功;eErrorNotFound 缺少 oid;eErrorInvalidParam 参数为空