Fixed some bugs in the update script

This commit is contained in:
Roger Far 2021-04-01 16:31:05 -06:00
parent d7c6c36118
commit c4a7c1e5ed
5 changed files with 36 additions and 8 deletions

View file

@ -4,10 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.7.1] - 2021-04-01
### Added
- Add Update.ps1 to automatically download the latest version from Github for Windows users.
## [1.7.0] - 2021-04-01
### Added
- Add automatic retry functionality for downloads. It will retry downloading a file after an error 3 times.
- Add Update.ps1 to automatically download the latest version from Github for Windows users.
### Changed
- Fixed an issue downloads sometimes getting added multiple times.

View file

@ -49,7 +49,7 @@
<a class="navbar-item"> Profile </a>
<a class="navbar-item" (click)="logout()"> Logout </a>
<hr class="navbar-divider" />
<div class="navbar-item">Version 1.7.0</div>
<div class="navbar-item">Version 1.7.1</div>
</div>
</div>
</div>

View file

@ -1,6 +1,6 @@
{
"name": "rdt-client",
"version": "1.7.0",
"version": "1.7.1",
"description": "This is a web interface to manage your torrents on Real-Debrid.",
"main": "index.js",
"dependencies": {

View file

@ -4,7 +4,7 @@
<TargetFramework>net5.0</TargetFramework>
<OutputType>Exe</OutputType>
<UserSecretsId>94c24cba-f03f-4453-a671-3640b517c573</UserSecretsId>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
</PropertyGroup>
<ItemGroup>

View file

@ -1,26 +1,51 @@
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
$currentDirectory = $PSScriptRoot
Write-Host "Starting update script in $currentDirectory"
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
Write-Host "Stopping ReadDebridClient..."
Stop-Service RealDebridClient
Write-Host "Stopped ReadDebridClient"
$releasesUri = "https://api.github.com/repos/rogerfar/rdt-client/releases/latest"
$downloadUri = ((Invoke-RestMethod -Method GET -Uri $releasesUri).assets | Where-Object name -like "*.zip").browser_download_url
Write-Host "Downloading $downloadUri"
$pathZip = Join-Path -Path $([System.IO.Path]::GetTempPath()) -ChildPath $(Split-Path -Path $downloadUri -Leaf)
Invoke-WebRequest -Uri $downloadUri -Out $pathZip
$tempExtract = Join-Path -Path $([System.IO.Path]::GetTempPath()) -ChildPath $((New-Guid).Guid)
Write-Host "Extracting to $tempExtract"
Expand-Archive -Path $pathZip -DestinationPath $tempExtract -Force
Copy-Item -Path ".\appsettings.json" -Destination $tempExtract -Force
Move-Item -Path "$tempExtract\*" -Destination $pathExtract -Force
Write-Host "Backing up appsettings.json"
Copy-Item -Path "$currentDirectory\appsettings.json" -Destination $tempExtract -Force
Write-Host "Moving new files"
Move-Item -Path "$tempExtract\*" -Destination $currentDirectory -Force
Write-Host "Removing temp files"
Remove-Item -Path $tempExtract -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item $pathZip -Force
Start-Service RealDebridClient
Write-Host "Starting ReadDebridClient..."
Start-Service RealDebridClient
Write-Host "Started ReadDebridClient"