1.2.0-rc1 #1
@@ -701,11 +701,17 @@ Function Get-GiteaChildItem {
|
|||||||
# Save the original download URL for LFS pointers to be used to populate the size and sha fields
|
# Save the original download URL for LFS pointers to be used to populate the size and sha fields
|
||||||
$GitLFSPointerURL = $item.download_url
|
$GitLFSPointerURL = $item.download_url
|
||||||
# Use the Gitea API to get the LFS pointer details
|
# Use the Gitea API to get the LFS pointer details
|
||||||
$lfsPointerResponse = Invoke-RestMethod -Uri $GitLFSPointerURL -Method Get -Headers $headers -ErrorAction Stop
|
# For LFS files, we need to get the pointer file and parse it for details
|
||||||
Write-Debug "LFS Pointer Response: $($lfsPointerResponse | ConvertTo-Json -Depth 1 -Compress)"
|
$lfsPointerContent = Invoke-RestMethod -Uri $GitLFSPointerURL -Method Get -Headers $headers -ErrorAction Stop
|
||||||
# Update the item with the LFS pointer details
|
Write-Debug "LFS Pointer Content: $($lfsPointerContent)"
|
||||||
$item.size = $lfsPointerResponse.size
|
|
||||||
$item.sha = $lfsPointerResponse.sha
|
# Parse the LFS pointer to extract size and SHA
|
||||||
|
if ($lfsPointerContent -match 'oid sha256:([a-f0-9]+)') {
|
||||||
|
$item.sha = $matches[1]
|
||||||
|
}
|
||||||
|
if ($lfsPointerContent -match 'size (\d+)') {
|
||||||
|
$item.size = [long]$matches[1]
|
||||||
|
}
|
||||||
# Set the download URL to the media endpoint for LFS files to download the actual file
|
# Set the download URL to the media endpoint for LFS files to download the actual file
|
||||||
$item.download_url = "$giteaURL/api/v1/repos/$repoOwner/$repoName/media/$($item.path)"
|
$item.download_url = "$giteaURL/api/v1/repos/$repoOwner/$repoName/media/$($item.path)"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user