diff --git a/bucket/curd.json b/bucket/curd.json index ddbcbc2360522e..7b5cf8aa3d5191 100644 --- a/bucket/curd.json +++ b/bucket/curd.json @@ -11,6 +11,55 @@ } }, "bin": "curd.exe", + "post_install": [ + "# --- Ensure persist_dir exists (not guaranteed without a persist array) ---", + "New-Item -ItemType Directory -Force \"$persist_dir\" | Out-Null", + "", + "# --- Config dir: %APPDATA%\\Curd -> junction to $persist_dir\\config ---", + "$appdata_config = \"$env:APPDATA\\Curd\"", + "if (!(Test-Path \"$persist_dir\\config\")) {", + " if (Test-Path $appdata_config) {", + " Move-Item $appdata_config \"$persist_dir\\config\"", + " } else {", + " New-Item -ItemType Directory -Force \"$persist_dir\\config\" | Out-Null", + " }", + "}", + "if ((Get-Item $appdata_config -ErrorAction SilentlyContinue).LinkType -ne 'Junction') {", + " if (Test-Path $appdata_config) { Remove-Item $appdata_config -Recurse -Force }", + " New-Item -ItemType Junction -Path $appdata_config -Target \"$persist_dir\\config\" | Out-Null", + "}", + "", + "# --- Patch StoragePath in config to point to $persist_dir\\storage ---", + "$cfg = \"$persist_dir\\config\\curd.conf\"", + "if (Test-Path $cfg) {", + " $content = Get-Content $cfg", + " if ($content -match '^StoragePath\\s*=') {", + " $content = $content -replace '^StoragePath\\s*=.*', \"StoragePath=$persist_dir\\storage\"", + " Set-Content $cfg $content", + " } else {", + " Add-Content $cfg \"`nStoragePath=$persist_dir\\storage\"", + " }", + "} else {", + " New-Item -ItemType File -Force $cfg | Out-Null", + " Set-Content $cfg \"StoragePath=$persist_dir\\storage\"", + "}", + "", + "# --- Migrate old storage from C:\\.local\\share\\curd if present ---", + "$old_storage = \"C:\\.local\\share\\curd\"", + "if ((Test-Path $old_storage) -and !(Test-Path \"$persist_dir\\storage\")) {", + " Move-Item $old_storage \"$persist_dir\\storage\"", + "}", + "", + "# --- Ensure storage dir exists regardless of migration ---", + "New-Item -ItemType Directory -Force \"$persist_dir\\storage\" | Out-Null" + ], + "pre_uninstall": [ + "# Remove the AppData junction but leave persist data intact", + "$appdata_config = \"$env:APPDATA\\Curd\"", + "if ((Get-Item $appdata_config -ErrorAction SilentlyContinue).LinkType -eq 'Junction') {", + " Remove-Item $appdata_config -Force", + "}" + ], "checkver": "github", "autoupdate": { "architecture": {