Skip to content

Commit 606b4e0

Browse files
committed
fix(sqlite): Add e_sqlite.dll downloading
1 parent 3a79532 commit 606b4e0

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

lib/core.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ function Complete-ConfigChange {
206206
}
207207

208208
if ($Name -eq 'use_sqlite_cache' -and $Value -eq $true) {
209-
if ((Get-DefaultArchitecture) -eq 'arm64') {
210-
abort 'SQLite cache is not supported on ARM64 platform.'
211-
}
212209
. "$PSScriptRoot\..\lib\database.ps1"
213210
. "$PSScriptRoot\..\lib\manifest.ps1"
214211
info 'Initializing SQLite cache in progress... This may take a while, please wait.'

lib/database.ps1

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
.SYNOPSIS
55
Get SQLite .NET driver
66
.DESCRIPTION
7-
Download and extract the SQLite .NET driver from NuGet.
7+
Download and extract the SQLite .NET driver and SQLite precompiled binaries.
8+
The SQLite version is automatically detected from the download page.
89
.PARAMETER Version
910
System.String
10-
The version of the SQLite .NET driver to download.
11+
The version of the System.Data.SQLite NuGet package to download. (require version 2.0.0 or higher)
1112
.INPUTS
1213
None
1314
.OUTPUTS
@@ -18,18 +19,41 @@ function Get-SQLite {
1819
param (
1920
[string]$Version = '2.0.2'
2021
)
21-
# Install SQLite
2222
try {
23-
Write-Host "Downloading System.Data.SQLite $Version..." -ForegroundColor DarkYellow
24-
$sqlitePkgPath = "$env:TEMP\sqlite.zip"
23+
$sqliteNetPath = "$env:TEMP\sqlite.net.zip"
24+
$sqliteDllPath = "$env:TEMP\sqlite.dll.zip"
2525
$sqliteTempPath = "$env:TEMP\sqlite"
2626
$sqlitePath = "$PSScriptRoot\..\supporting\sqlite"
27-
Invoke-WebRequest -Uri "https://globalcdn.nuget.org/packages/system.data.sqlite.$version.nupkg" -OutFile $sqlitePkgPath
28-
Write-Host "Extracting System.Data.SQLite $Version... " -ForegroundColor DarkYellow -NoNewline
29-
Expand-Archive -Path $sqlitePkgPath -DestinationPath $sqliteTempPath -Force
30-
New-Item -Path $sqlitePath -ItemType Directory -Force | Out-Null
27+
28+
$arch = switch (Get-DefaultArchitecture) {
29+
'32bit' { 'x86' }
30+
'64bit' { 'x64' }
31+
'arm64' { 'arm64' }
32+
default { Write-Warning "Unknown architecture, using x64 as fallback"; 'x64' }
33+
}
34+
35+
Write-Host "Downloading System.Data.SQLite $Version..." -ForegroundColor DarkYellow
36+
Invoke-WebRequest -Uri "https://globalcdn.nuget.org/packages/system.data.sqlite.$Version.nupkg" -OutFile $sqliteNetPath
37+
38+
$downloadPage = Invoke-WebRequest -Uri 'https://sqlite.org/download.html' -UseBasicParsing
39+
if ($downloadPage.Content -match '(?s)<!-- Download product data.*?(PRODUCT,.+?)-->') {
40+
$productData = $Matches[1] | ConvertFrom-Csv
41+
} else {
42+
throw "Failed to parse SQLite download page product data"
43+
}
44+
$matchRow = $productData | Where-Object { $_.'RELATIVE-URL' -match "sqlite-dll-win-$arch-" }
45+
if (-not $matchRow) {
46+
throw "SQLite DLL for architecture $arch not found"
47+
}
48+
Write-Host "Downloading SQLite DLL $($matchRow.VERSION)..." -ForegroundColor DarkYellow
49+
Invoke-WebRequest -Uri "https://sqlite.org/$($matchRow.'RELATIVE-URL')" -OutFile $sqliteDllPath
50+
51+
Write-Host "Extracting libraries... " -ForegroundColor DarkYellow -NoNewline
52+
$sqliteNetPath, $sqliteDllPath | Expand-Archive -DestinationPath $sqliteTempPath -Force
53+
$null = New-Item -Path "$sqlitePath\$arch" -ItemType Directory -Force
3154
Move-Item -Path "$sqliteTempPath\lib\netstandard2.0\System.Data.SQLite.dll" -Destination $sqlitePath -Force
32-
Remove-Item -Path $sqlitePkgPath, $sqliteTempPath -Recurse -Force
55+
Move-Item -Path "$sqliteTempPath\sqlite3.dll" -Destination "$sqlitePath\$arch\e_sqlite3.dll" -Force
56+
Remove-Item -Path $sqliteNetPath, $sqliteDllPath, $sqliteTempPath -Recurse -Force
3357
Write-Host 'Done.' -ForegroundColor DarkYellow
3458
return $true
3559
} catch {

0 commit comments

Comments
 (0)