|
🛰️航天仿真算法库 SpaceAST 0.3.1
|
类 | |
| 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) |
| using ast::DownloadProgressCallback = std::function<bool(uint64_t downloaded, uint64_t total)> |
下载进度回调:downloaded 为已下载字节数;total 为总字节数,为 0 表示未知
| AST_UTIL_CAPI errc_t ast::aDownloadLfs | ( | StringView | pointerFile, |
| StringView | outputFile, | ||
| StringView | remoteUrl ) |
下载 Git LFS 对象到本地文件
发送 POST batch 请求换取带签名的下载地址,再 GET 下载。 对象先写入 outputFile+".part",成功后才重命名为 outputFile, 任何失败都会清理临时文件,避免在目标路径残留截断/伪冒文件。
| pointerFile | 指针文件路径 |
| outputFile | 目标文件路径 |
| remoteUrl | git 远端地址(如 https://github.com/<owner>/<repo>.git) |
| 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 | 对象字节数 |
| 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
| remoteUrl | git 远端地址 |
| 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 为空 |