diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b178d3..bf29d5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,16 @@ ### Removed +## [0.1.2] - 2023-06-13 + +### Fixed + +- Fix the bug on windows which erased DeepFaceLabClient when trying to install a release (/!\ the bug is still present in earlier versions) + ## [0.1.1] - 2023-06-13 +Note: on this version installing another release doesn't work (on windows), you need to install it manually from the github. + ### Fixed - Fix download Miniconda3-latest-Linux-x86_64.sh with no certificate @@ -19,6 +27,8 @@ ## [0.1.0] - 2023-06-12 +Note: on this version installing another release doesn't work (on windows), you need to install it manually from the github. + ### Added - Install requirements (linux) diff --git a/lib/service/platform_service.dart b/lib/service/platform_service.dart index f915db6..7c42515 100644 --- a/lib/service/platform_service.dart +++ b/lib/service/platform_service.dart @@ -8,4 +8,12 @@ class PlatformService { } return Platform.environment[path] ?? Platform.pathSeparator; } + + static getReleaseFilename() { + var fileName = 'install_release.sh'; + if (Platform.isWindows) { + fileName = 'install_release.bat'; + } + return fileName; + } } diff --git a/lib/widget/common/release_widget.dart b/lib/widget/common/release_widget.dart index b50a5ad..9627281 100644 --- a/lib/widget/common/release_widget.dart +++ b/lib/widget/common/release_widget.dart @@ -5,6 +5,7 @@ import 'package:collection/collection.dart'; import 'package:deepfacelab_client/class/app_state.dart'; import 'package:deepfacelab_client/class/release.dart'; import 'package:deepfacelab_client/class/release_asset.dart'; +import 'package:deepfacelab_client/service/platform_service.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -99,14 +100,16 @@ class ReleaseWidget extends HookWidget { // region see .github/workflows/release.yml var createdFolder = 'DeepFaceLabClient-linux'; var platform = 'linux'; - var file = 'install_release.sh'; if (Platform.isWindows) { createdFolder = 'DeepFaceLabClient-windows'; platform = 'windows'; - file = 'install_release.bat'; } + var releaseFilename = PlatformService.getReleaseFilename(); + var scriptFile = await File( + "${Directory.current.path}${Platform.pathSeparator}script${Platform.pathSeparator}$platform${Platform.pathSeparator}$releaseFilename") + .copy(folderPath + Platform.pathSeparator + releaseFilename); Process.run( - "${Directory.current.path}${Platform.pathSeparator}script${Platform.pathSeparator}$platform${Platform.pathSeparator}$file", + scriptFile.path, [ folderName, folderPath, diff --git a/pubspec.yaml b/pubspec.yaml index 888c806..8918031 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.1.1 +version: 0.1.2 environment: sdk: '>=2.19.4 <3.0.0' diff --git a/script/linux/install_release.sh b/script/linux/install_release.sh index 8e4d4c9..ca14741 100755 --- a/script/linux/install_release.sh +++ b/script/linux/install_release.sh @@ -1,16 +1,17 @@ set -e -#just to be sure that DeepFaceLabClient is closed -sleep 2 - folderName=$1 folderPath=$2 downloadFileName=$3 execPath=$4 createdFolder=$5 +#just to be sure that DeepFaceLabClient is closed +sleep 2 + rm -rf $folderPath/$folderName unzip -o $folderPath/$downloadFileName -d $folderPath #to preserve shortcut and symbolic link mv $folderPath/$createdFolder $folderPath/$folderName -$execPath \ No newline at end of file +rm $folderPath/$downloadFileName +$execPath & rm $folderPath/install_release.sh \ No newline at end of file diff --git a/script/windows/install_release.bat b/script/windows/install_release.bat index 0896a69..707c140 100755 --- a/script/windows/install_release.bat +++ b/script/windows/install_release.bat @@ -1,16 +1,18 @@ @echo off -@REM just to be sure that DeepFaceLabClient is closed -timeout 2 - set folderName=%1 set folderPath=%2 set downloadFileName=%3 set execPath=%4 set createdFolder=%5 -if exist %folderPath%\%folderName% rmdir %folderPath%\%folderName% /q /s +powershell -command "Start-Sleep -s 2" + tar -xf %folderPath%\%downloadFileName% -C %folderPath% -@REM to preserve shortcut and symbolic link -move %folderPath%\%createdFolder% %folderPath%\%folderName% -%execPath% +if %createdFolder% neq %folderName% ( + xcopy %folderPath%\%createdFolder% %folderPath%\%folderName% /Y /S + rmdir /s /q %folderPath%\%createdFolder% +) +del %folderPath%\%downloadFileName% +start /b "" cmd /c %execPath% /b +start /b "" cmd /c del %folderPath%\install_release.bat&exit /b