{
    "version": "1.9.3",
    "description": "A modern download manager that supports all platforms.",
    "homepage": "https://gopeed.com",
    "license": {
        "identifier": "GPL-3.0-or-later",
        "url": "https://github.com/GopeedLab/gopeed/blob/HEAD/LICENSE"
    },
    "notes": [
        "Starting with version 1.8.0, all user data is stored in the './storage' directory.",
        "Upgrading Gopeed via Scoop will no longer result in loss of user configuration."
    ],
    "architecture": {
        "64bit": {
            "url": "https://github.com/GopeedLab/gopeed/releases/download/v1.9.3/Gopeed-v1.9.3-windows-amd64-portable.zip",
            "hash": "02b3b2f0ce4b0e0008edc835802ad6f4b241eb863f312b0bdd77b2b2afc9e012"
        },
        "arm64": {
            "url": "https://github.com/GopeedLab/gopeed/releases/download/v1.9.3/Gopeed-v1.9.3-windows-arm64-portable.zip",
            "hash": "48a85f30ac94e72d1427f28f1465d5e79b1e8ab252c2a3ad408ae5c1c8bfd915"
        }
    },
    "pre_install": [
        "if ($cmd -eq \"install\") { return }",
        "$threshold_version = [version]\"1.7.1\"",
        "$parent_dir = Split-Path $dir -Parent",
        "# Get version directories, ignore '_' prefixed, sort by version descending",
        "$version_dirs = Get-ChildItem -Path $parent_dir -Directory | Where-Object {",
        "    $_.Name -notmatch '^_' -and ($_.Name -as [version])",
        "} | Sort-Object { [version]$_.Name } -Descending",
        "if ($version_dirs.Count -lt 2) { return }",
        "$previous_version = [version]$version_dirs[1].Name",
        "info \"Detected previous version: $previous_version\"",
        "$storage_dir = Join-Path $persist_dir \"storage\"",
        "if ($previous_version -gt $threshold_version) {",
        "    info \"Previous version ($previous_version) is newer than threshold ($threshold_version).\"",
        "    info \"User data from the previous version already exists in $storage_dir.\"",
        "    info \"And it has been successfully persisted, therefore no additional copy operation is required.\"",
        "    return",
        "}",
        "info \"Previous version ($previous_version) is older than or equal to threshold ($threshold_version).\"",
        "info \"Attempting to copy data requiring persistence to $storage_dir...\"",
        "if (-not (Test-Path $storage_dir)) {",
        "    New-Item -Path $storage_dir -ItemType Directory -Force | Out-Null",
        "}",
        "'gopeed.db', 'logs', 'extensions' | ForEach-Object {",
        "    $user_data_path = Join-Path $version_dirs[1].FullName $_",
        "    if (Test-Path $user_data_path) {",
        "        info \"Found $_ at $user_data_path.\"",
        "        info \"Starting copy to $storage_dir...\"",
        "        Copy-Item -Path $user_data_path -Destination $storage_dir -Force -Recurse",
        "        info \"Successfully copied $_ to $storage_dir.\"",
        "    } else {",
        "        info \"Item not found: $user_data_path (skipped).\"",
        "    }",
        "}"
    ],
    "shortcuts": [
        [
            "gopeed.exe",
            "Gopeed"
        ]
    ],
    "persist": "storage",
    "checkver": {
        "github": "https://github.com/GopeedLab/gopeed"
    },
    "autoupdate": {
        "architecture": {
            "64bit": {
                "url": "https://github.com/GopeedLab/gopeed/releases/download/v$version/Gopeed-v$version-windows-amd64-portable.zip"
            },
            "arm64": {
                "url": "https://github.com/GopeedLab/gopeed/releases/download/v$version/Gopeed-v$version-windows-arm64-portable.zip"
            }
        }
    }
}
