diff --git a/functions/ToolScripts/emuDeckSaveSync.ps1 b/functions/ToolScripts/emuDeckSaveSync.ps1
index 80aadf3d..a3c91c62 100644
--- a/functions/ToolScripts/emuDeckSaveSync.ps1
+++ b/functions/ToolScripts/emuDeckSaveSync.ps1
@@ -160,6 +160,15 @@ $scriptContent = @"
function cloud_sync_install($cloud_sync_provider){
#startLog($MyInvocation.MyCommand.Name)
+ $batFilePath = "$env:APPDATA\EmuDeck\backend\tools\cloudSync\cloud_sync_force.bat"
+ $shortcutPath = "$env:USERPROFILE\Desktop\Force CloudSync.lnk"
+ $iconPath = "$env:USERPROFILE/AppData/Local/Programs/EmuDeck/EmuDeck.exe"
+ $wshShell = New-Object -ComObject WScript.Shell
+ $shortcut = $wshShell.CreateShortcut($shortcutPath)
+ $shortcut.TargetPath = $batFilePath
+ $shortcut.IconLocation = $iconPath
+ $shortcut.Save()
+
confirmDialog -TitleText "Administrator Privileges needed" -MessageText "During the installation of CloudSync you'll get several windows asking for elevated permissions. This is so we can create symlinks, a background service and set its proper permissions. Please accept all of them"
@@ -616,7 +625,7 @@ function cloud_sync_downloadEmu($emuName, $mode){
if (Test-Path "$cloud_sync_bin") {
#We check for internet connection
if ( check_internet_connection -eq 'true' ){
-
+ Stop-Process -Name "Rclone" -Force -ErrorAction SilentlyContinue
#Do we have a pending upload?
if (Test-Path "$savesPath/$emuName/.pending_upload") {
@@ -700,6 +709,7 @@ function cloud_sync_uploadEmu{
if (Test-Path "$cloud_sync_bin") {
#We check for internet connection
if ( check_internet_connection -eq 'true' ){
+ Stop-Process -Name "Rclone" -Force -ErrorAction SilentlyContinue
#Do we have a failed download?
if (Test-Path "$savesPath/$emuName/.fail_upload") {
$date = Get-Content "$savesPath/$emuName/.fail_upload"
diff --git a/functions/cloudSyncHealth.ps1 b/functions/cloudSyncHealth.ps1
index a19ac8c7..6b5e4c8b 100644
--- a/functions/cloudSyncHealth.ps1
+++ b/functions/cloudSyncHealth.ps1
@@ -1,84 +1,137 @@
-function cloud_sync_download_test($emuName){
- if ((Test-Path "$cloud_sync_bin") -and ($cloud_sync_status -eq $true)) {
-
- $target = "$emulationPath\saves\$emuName\"
- if ( Test-Path "$target" ){
- "test" | Set-Content "$target\.temp" -ErrorAction SilentlyContinue -Encoding UTF8
- $fileHash = "$target\.temp"
-
-
- & $cloud_sync_bin -q --log-file "$userFolder/EmuDeck/logs/rclone.log" copyto --fast-list --checkers=50 --transfers=50 --low-level-retries 1 --retries 1 "$cloud_sync_provider`:Emudeck\saves\$emuName\.temp" "$fileHash"
- if ($?) {
- echo "
"
+ $watcherStatus=1
+ $upload=1
+ $download=1
-function cloud_sync_upload_test($emuNAme){
- if ((Test-Path "$cloud_sync_bin") -and ($cloud_sync_status -eq $true)) {
+ $result = yesNoDialog -TitleText "CloudSync Health" -MessageText "Do you use EmulationStation to launch your games?" -OKButtonText "Yes" -CancelButtonText "No"
- $target = "$emulationPath\saves\$emuName\"
- if ( Test-Path "$target" ){
- "test" | Set-Content "$target\.temp" -ErrorAction SilentlyContinue -Encoding UTF8
- $fileHash = "$target\.temp"
+ if ($result -eq "OKButton") {
+ #Launching ESDE
+ Start-Process powershell.exe -ArgumentList "-ExecutionPolicy Bypass -File `"$toolsPath/launchers/esde/EmulationStationDE.ps1`" "
- & $cloud_sync_bin -q --log-file "$userFolder/EmuDeck/logs/rclone.log" copyto --fast-list --checkers=50 --transfers=50 --low-level-retries 1 --retries 1 "$fileHash" "$cloud_sync_provider`:Emudeck\saves\$emuName\.temp"
- if ($?) {
- echo "
$elemento upload Status: | Success |
"
- }else{
- echo "
$elemento upload Status: | Failure |
"
- rm -fo -r "$target\.temp" -ErrorAction SilentlyContinue
- exit
- }
- rm -fo -r "$target\.temp" -ErrorAction SilentlyContinue
- }
+ } else {
+ $kill = "RETROARCH"
+ Start-Process powershell.exe -ArgumentList "-ExecutionPolicy Bypass -File `"$toolsPath/launchers/retroarch.ps1`" "
+ }
+ if ($kill -eq "RETROARCH") {
+ while (-not (Get-Process -Name "retroarch" -ErrorAction SilentlyContinue)) {
+ echo "waiting for RA to open"
+ Start-Sleep -Seconds 2
}
+ }else{
+ while (-not (Get-Process -Name "ES-DE" -ErrorAction SilentlyContinue)) {
+ echo "waiting for ESDE to open"
+ Start-Sleep -Seconds 2
+ }
+ }
+ Start-Sleep -Seconds 5
+ echo "Creating test file"
+ echo "testing upload" > "$savesPath/retroarch/test_emudeck.txt"
-}
+ while (-not (Get-Process -Name "rclone" -ErrorAction SilentlyContinue)) {
+ echo "waiting for rclone to open"
+ Start-Sleep -Seconds 1
+ }
-function cloudSyncHealth(){
- echo "
"
- echo ""
- if ( -not (Test-Path "$toolsPath\rclone\rclone.exe")) {
- echo "Executable Status: | Failure, please reinstall | "
- exit
- }else{
- echo "Executable Status: | Success | "
- }
- echo "
"
- if ( -not (Test-Path "$toolsPath\rclone\rclone.conf")) {
- echo "Config file Status: | Failure, please reinstall | "
- exit
- }else{
- echo "Config file Status: | Success | "
- }
- echo "
"
- if ( $cloud_sync_provider -eq '') {
- echo "Provider Status: | Failure, please reinstall | "
- exit
- }else{
- echo "Provider Status: | Success | "
- }
- echo "
"
- $miArreglo = @("retroarch")
+ while (Get-Process -Name "rclone" -ErrorAction SilentlyContinue) {
+ echo "waiting for rclone to finish"
+ Start-Sleep -Seconds 1
+ }
- foreach ($elemento in $miArreglo) {
- cloud_sync_upload_test $elemento
- }
+ $result = & $cloud_sync_bin lsf "$cloud_sync_provider`:Emudeck/saves/retroarch/" | Select-String "test_emudeck.txt"
+
+ # Evaluar el resultado
+ if ($result) {
+ Write-Host "file exists in the cloud. SUCCESS"
+ $upload = 0
+ } else {
+ Write-Host "file does not exist in the cloud. FAIL"
+ }
+
+
+ #
+ ##Testing Dowmload
+ #
+
+ & "$cloud_sync_bin" --progress copyto -L --fast-list --checkers=50 --transfers=50 --low-level-retries 1 --retries 1 "$cloud_sync_provider`:Emudeck/saves/retroarch/test_emudeck.txt" "$savesPath/retroarch/test_emudeck.txt"
+
+ if (Test-Path "$savesPath\retroarch\test_emudeck.txt") {
+ Write-Host "file exists in local. SUCCESS"
+ $download = 0
+ } else {
+ Write-Host "file does not exist in local. FAIL"
+ }
+
+ # Eliminar los directorios y archivos locales
+ Remove-Item -Recurse -Force "$savesPath\.watching"
+ Remove-Item -Recurse -Force "$savesPath\retroarch\test_emudeck.txt"
+
+ # Eliminar el archivo remoto
+ & $cloud_sync_bin delete "$cloud_sync_provider`:Emudeck/saves/retroarch/test_emudeck.txt"
+
+ # Verificar si se debe matar Retroarch o cerrar otra ventana
+ if ($kill -eq "RETROARCH") {
+ Stop-Process -Name "RetroArch" -Force
+ } else {
+ Stop-Process -Name "ES-DE" -Force
+ }
+
+ Write-Host ""
+
+ Write-Host ""
+ Write-Host ""
+
+ # Check installation
+ if (-Not (Test-Path $cloud_sync_bin)) {
+ Write-Host "Executable Status: | Failure, please reinstall |
"
+ exit
+ } else {
+ Write-Host "Executable Status: | Success | "
+ }
+ Write-Host ""
+
+ if (-Not (Test-Path $cloud_sync_config_file)) {
+ Write-Host "Config file Status: | Failure, please reinstall |
"
+ exit
+ } else {
+ Write-Host "
Config file Status: | Success | "
+ }
+ Write-Host "
"
+
+ if ([string]::IsNullOrEmpty($cloud_sync_provider)) {
+ Write-Host "Provider Status: | Failure, please reinstall |
"
+ exit
+ } else {
+ Write-Host "
Provider Status: | Success | "
+ }
+ Write-Host "
"
+
+ # Tests upload
+ Write-Host "
"
+ if ($upload -eq 0) {
+ Write-Host "Upload Status: | Success | "
+ } else {
+ Write-Host "Upload Status: | Failure | "
+ Write-Host "
"
+ }
+ Write-Host ""
+
+ # Tests download
+ Write-Host "
"
+ if ($download -eq 0) {
+ Write-Host "Download Status: | Success | "
+ } else {
+ Write-Host "Download Status: | Failure | "
+ Write-Host "
"
+ }
+ Write-Host ""
+
+ Write-Host ""
+ Write-Host "
true"
- foreach ($elemento in $miArreglo) {
- cloud_sync_download_test $elemento
- }
- echo "
"
- Write-Host "true"
}
\ No newline at end of file
diff --git a/tools/cloudSync/cloud_sync_force.bat b/tools/cloudSync/cloud_sync_force.bat
new file mode 100644
index 00000000..2a9aec13
--- /dev/null
+++ b/tools/cloudSync/cloud_sync_force.bat
@@ -0,0 +1 @@
+powershell -ExecutionPolicy Bypass -NoExit . %APPDATA%\EmuDeck\backend\tools\cloudSync\cloud_sync_force.ps1
\ No newline at end of file
diff --git a/tools/cloudSync/cloud_sync_force.ps1 b/tools/cloudSync/cloud_sync_force.ps1
new file mode 100644
index 00000000..da527923
--- /dev/null
+++ b/tools/cloudSync/cloud_sync_force.ps1
@@ -0,0 +1,12 @@
+. "$env:USERPROFILE/AppData/Roaming/EmuDeck/backend/functions/allCloud.ps1"
+$result = yesNoDialog -TitleText "CloudSync Force" -MessageText "Do you want to force the download or the upload" -OKButtonText "Upload" -CancelButtonText "Download"
+
+if ($result -eq "OKButton") {
+ $dialog = steamToast -MessageText "Uploading all systems... don't turn off your device"
+ cloud_sync_uploadEmuAll
+ $dialog.Close()
+} else {
+ $dialog = steamToast -MessageText "Downloading all systems... don't turn off your device"
+ cloud_sync_downloadEmuAll
+ $dialog.Close()
+}
\ No newline at end of file
diff --git a/tools/cloudSync/cloud_sync_watcher_user.ps1 b/tools/cloudSync/cloud_sync_watcher_user.ps1
index 574a3920..cfdbbb73 100644
--- a/tools/cloudSync/cloud_sync_watcher_user.ps1
+++ b/tools/cloudSync/cloud_sync_watcher_user.ps1
@@ -73,7 +73,7 @@ try
$skip = $blackList | ForEach-Object { $FullPath -like "*$_" }
if($skip -contains $true){
- echo "Ignoring blacklisted file"
+ Write-Host "Ignoring blacklisted file"
return
}
@@ -86,7 +86,7 @@ try
# Check if the file was modified in the last 2 seconds
$lastModifiedTime = $lastModifiedTimes[$FullPath]
if ($lastModifiedTime -and ($Timestamp).Subtract($lastModifiedTime).TotalMilliseconds -lt 500) {
- echo "Ignoring $FullPath because it was modified again too quickly."
+ Write-Host "Ignoring $FullPath because it was modified again too quickly."
return
}
@@ -103,8 +103,8 @@ try
# let's compose a message:
$text = "{0} was {1} at {2}" -f $FullPath, $ChangeType, $Timestamp
- echo ""
- echo $text -ForegroundColor DarkYellow
+ Write-Host ""
+ Write-Host $text -ForegroundColor DarkYellow
# you can also execute code based on change type here:
switch ($ChangeType)
@@ -112,7 +112,7 @@ try
'Changed' {
if ($skip -contains $true -or $FullPath -eq $savesPath -or $FullPath -eq $emuPath) {
- echo "No upload"
+ Write-Host "No upload"
} else {
$toast = steamToast -MessageText "CloudSync - Uploading Modified file"
Get-Date -Format "yyyy-MM-dd HH:mm:ss" | Out-File -FilePath $savesPath/$emuName/.pending_upload
@@ -124,7 +124,7 @@ try
}
'Created' {
if ($skip -contains $true -or $FullPath -eq $savesPath -or $FullPath -eq $emuPath) {
- echo "No upload"
+ Write-Host "No upload"
} else {
$toast = steamToast -MessageText "CloudSync - Uploading new file"
Get-Date -Format "yyyy-MM-dd HH:mm:ss" | Out-File -FilePath $savesPath/$emuName/.pending_upload
@@ -139,18 +139,18 @@ try
# to illustrate that ALL changes are picked up even if
# handling an event takes a lot of time, we artificially
# extend the time the handler needs whenever a file is deleted
- echo "Deletion Handler Start"
+ Write-Host "Deletion Handler Start"
Start-Sleep -Seconds 4
- echo "Deletion Handler End"
+ Write-Host "Deletion Handler End"
}
'Renamed' {
# this executes only when a file was renamed
$text = "File {0} was renamed to {1}" -f $OldName, $Name
- echo $text
+ Write-Host $text
}
# any unhandled change types surface here:
- default { echo $_ }
+ default { Write-Host $_ }
}
}
@@ -167,7 +167,7 @@ try
# monitoring starts now:
$watcher.EnableRaisingEvents = $true
- echo "Watching for changes to $Path"
+ Write-Host "Watching for changes to $Path"
# since the FileSystemWatcher is no longer blocking PowerShell
# we need a way to pause PowerShell while being responsive to
@@ -179,7 +179,7 @@ try
Wait-Event -Timeout 1
# write a dot to indicate we are still monitoring:
- echo "." -NoNewline
+ Write-Host "." -NoNewline
# Process name to find
$processName = "EmuDeck Launcher"
@@ -192,13 +192,13 @@ try
# We exit if it doesn't
if (-not (Test-Path $cmdFile)) {
- echo "There's no .watching file"
+ Write-Host "There's no .watching file"
$dialog = steamToast -MessageText "Uploading... don't turn off your device"
Add-Type -AssemblyName System.speech
# Check for lock file
if (-not (Test-Path $lockFile)) {
$dialog.Close()
- echo "There's no lock file, bye!"
+ Write-Host "There's no lock file, bye!"
$dialog = steamToast -MessageText "Sync Completed! You can safely turn off your device"
& $nssm stop CloudWatch
$dialog.Close()
|