Skip to content

Commit

Permalink
Fixed updating feature
Browse files Browse the repository at this point in the history
  • Loading branch information
nonepork committed Nov 22, 2024
1 parent 6ecdaf2 commit 1fc46d8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
44 changes: 41 additions & 3 deletions website/public/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,53 @@ $filename = "$package-windows-v$version-$arch.zip"

$ProgressPreference = 'SilentlyContinue' #speeds up Download massively, but doesnt show Bits written

Write-Host "Downloading superfile..."
Write-Host "Checking for superfile installation..."

$superfileProgramPath = [Environment]::GetFolderPath("LocalApplicationData") + "\Programs\superfile"
$superfileExePath = $superfileProgramPath + "\spf.exe"

if (-not (Test-Path $superfileProgramPath)) {
New-Item -Path $superfileProgramPath -ItemType Directory -Verbose:$false | Out-Null
} else {
Write-Host "Folder $superfileProgramPath already exists. :/"
exit
if (Test-Path $superfileExePath) {
$versionOutput = & $superfileExePath --version
$versionOutput = $versionOutput.Replace('superfile version v', '')

$currentVersionParts = $version -split '\.' | ForEach-Object { [int]$_ }
$installedVersionParts = $versionOutput -split '\.' | ForEach-Object { [int]$_ }

# Compare versions part by part
$isUpToDate = $true
for ($i = 0; $i -lt $currentVersionParts.Count; $i++) {
if ($currentVersionParts[$i] -gt $installedVersionParts[$i]) {
$isUpToDate = $false
break
} elseif ($currentVersionParts[$i] -lt $installedVersionParts[$i]) {
continue
}
}
if ($isUpToDate) {
Write-Host "superfile already installed, quitting..."
} else {
Write-Host "Old version (superfile v$versionOutput) found, removing..."
try {
if (Test-Path $superfileExePath) {
Remove-Item -Path $superfileExePath -Force
}
}
catch {
Write-Host "An error occurred: $_"
exit
}
}
} else {
Write-Host "superfile folder found but not executable :/, please check your %localappdata%\Programs\superfile for conflict."
exit
}
}

Write-Host "Downloading superfile..."

$url = "https://github.com/yorukot/superfile/releases/download/v$version/$filename"
try {
Invoke-WebRequest -OutFile "$superfileProgramPath/$filename" $url
Expand Down
2 changes: 1 addition & 1 deletion website/public/uninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Write-Host "Removing folder..."
$superfileProgramPath = [Environment]::GetFolderPath("LocalApplicationData") + "\Programs\superfile"
try {
if (Test-Path $superfileProgramPath) {
Remove-Item -Path $superfileProgramPath -Recurse -Force
Remove-Item -Path $superfileProgramPath -Recurse -Force
}
}
catch {
Expand Down

0 comments on commit 1fc46d8

Please sign in to comment.