This commit is contained in:
Frank Skare
2020-05-04 05:50:29 +02:00
parent 28045ad33e
commit 51f9e17380
4 changed files with 58 additions and 7 deletions

View File

@@ -5,6 +5,13 @@
5.4.6.0
=======
- youtube-dl update
- auto update routine fix
5.4.5.1 Beta
============

View File

@@ -229,4 +229,4 @@ namespace mpvnet
{
public static string Startup { get; } = Application.StartupPath + @"\";
}
}
}

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.4.5.1")]
[assembly: AssemblyFileVersion("5.4.5.1")]
[assembly: AssemblyVersion("5.4.6.0")]
[assembly: AssemblyFileVersion("5.4.6.0")]

View File

@@ -1,23 +1,67 @@
$ErrorActionPreference = 'Stop'
$targetDir = (Split-Path $args[1]) + "\new version"
if ($args.Length -ne 2) {
Write-Host 'Invalid arguments' -ForegroundColor Red
exit
}
if (-not (Get-Command curl.exe)) {
Write-Host 'Error using curl.exe' -ForegroundColor Red
exit
}
if ($PSVersionTable.PSVersion.Major -lt 5) {
Write-Host 'PowerShell 5.1 not found' -ForegroundColor Red
exit
}
Add-Type -AssemblyName Microsoft.VisualBasic
# Delete directory using recycle bin
function Remove-Directory($directory) {
if (Test-Path $directory) {
[Microsoft.VisualBasic.FileIO.FileSystem]::
DeleteDirectory($directory, 'OnlyErrorDialogs', 'SendToRecycleBin')
}
}
$currentDir = $args[1];
$targetDir = (Split-Path $currentDir) + "\new version"
Remove-Directory $targetDir
$targetFile = $targetDir + '.7z'
Remove-Item $targetFile -Force -ErrorAction Ignore
Write-Host 'Download new version' -ForegroundColor Green
curl.exe $args[0] --location --output $targetFile
if ($LastExitCode) { throw $LastExitCode }
Write-Host 'Unpack new version' -ForegroundColor Green
& ($args[1] + '\7z\7za.exe') x -y $targetFile -o"$targetDir"
& ($currentDir + '\7z\7za.exe') x -y $targetFile -o"$targetDir"
if ($LastExitCode) { throw $LastExitCode }
Write-Host 'Delete downloaded file' -ForegroundColor Green
Remove-Item $targetFile -Force -Recurse
$portableConfigDir = $currentDir + '\portable_config'
$portableConfigTempDir = (Split-Path $currentDir) + '\portable config dir temp'
Remove-Item $portableConfigTempDir -Force -ErrorAction Ignore
if (Test-Path $portableConfigDir) {
Write-Host 'Backup portable config' -ForegroundColor Green
Copy-Item $portableConfigDir $portableConfigTempDir -Recurse -Force
}
Write-Host 'Delete current version' -ForegroundColor Green
Remove-Item $args[1] -Force -Recurse
Remove-Directory $currentDir
Write-Host 'Rename directory' -ForegroundColor Green
Rename-Item $targetDir (Split-Path $args[1] -Leaf)
Rename-Item $targetDir (Split-Path $currentDir -Leaf)
if (Test-Path $portableConfigTempDir) {
Write-Host 'Restore portable config' -ForegroundColor Green
Move-Item $portableConfigTempDir $portableConfigDir -Force
}
Write-Host 'Update is complete' -ForegroundColor Green