Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sqlite): Use SQLite for caching apps #5851

Merged
merged 15 commits into from Apr 19, 2024
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@ test/installer/tmp/*
test/tmp/*
*~
TestResults.xml
supporting/sqlite/*
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -52,6 +52,7 @@
- **decompress:** Disable progress bar to improve `Expand-Archive` performance ([#5410](https://github.com/ScoopInstaller/Scoop/issues/5410))
- **scoop-search:** Improve performance for local search ([#5324](https://github.com/ScoopInstaller/Scoop/issues/5324))
- **shim:** Update kiennq-shim to v3.1.1 ([#5841](https://github.com/ScoopInstaller/Scoop/issues/5841), ([#5847](https://github.com/ScoopInstaller/Scoop/issues/5847)))
- **scoop-search:** Use SQLite for caching apps to speed up local search ([#5851](https://github.com/ScoopInstaller/Scoop/issues/5851))

### Code Refactoring

Expand Down
25 changes: 25 additions & 0 deletions lib/core.ps1
Expand Up @@ -142,11 +142,36 @@ function set_config {
$scoopConfig.PSObject.Properties.Remove($name)
}

# Initialize config's change
Complete-ConfigChange -Name $name -Value $value

# Save config with UTF8NoBOM encoding
ConvertTo-Json $scoopConfig | Out-UTF8File -FilePath $configFile
return $scoopConfig
}

function Complete-ConfigChange {
[CmdletBinding()]
param (
[Parameter(Mandatory, Position = 0)]
[string]
$Name,
[Parameter(Mandatory, Position = 1)]
[AllowEmptyString()]
[string]
$Value
)

if ($Name -eq 'use_sqlite_cache' -and $Value) {
. "$PSScriptRoot\..\lib\database.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"
info 'SQLite cache is enabled.'
New-ScoopDB
info 'Initializing cache in progress... This may take a while, please wait.'
Set-ScoopDB
}
}

function setup_proxy() {
# note: '@' and ':' in password must be escaped, e.g. 'p@ssword' -> p\@ssword'
$proxy = get_config PROXY
Expand Down