#!/bin/bash cloud_sync_upload_test(){ local emuName=$1 if [ ! -d $savesPath/$emuName ];then return 2 fi echo "test" > "$savesPath/$emuName/.temp" filePath="$savesPath/$emuName/.temp" "$cloud_sync_bin" -q copyto --fast-list --checkers=50 --transfers=50 --low-level-retries 1 --retries 1 "$filePath" "$cloud_sync_provider":"$cs_user"Emudeck/saves/$emuName/.temp && rm -rf "$savesPath/$emuName/.temp" && return 0 || return 1 } cloud_sync_dowload_test(){ local emuName=$1 if [ ! -d $savesPath/$emuName ];then return 2 fi echo "test" > "$savesPath/$emuName/.temp" filePath="$savesPath/$emuName/.temp" "$cloud_sync_bin" -q copyto --fast-list --checkers=50 --transfers=50 --low-level-retries 1 --retries 1 "$cloud_sync_provider":"$cs_user"Emudeck/saves/$emuName/.temp "$filePath" && rm -rf "$savesPath/$emuName/.temp" && return 0 || return 1 } cloudSyncHealth(){ echo "testing upload" > "$savesPath/retroarch/test_emudeck.txt" local watcherStatus=1 local upload=1 local download=1 touch "$emudeckLogs/cloudHealth.log" { cloud_sync_stopService #We start the service and check if it works if [ $(check_internet_connection) == "true" ]; then #Change path to a new test place echo "internet ok" else text="$(printf "CloudSync Error.\nInternet connection not available.")" zenity --error \ --title="EmuDeck" \ --width=400 \ --text="${text}" 2>/dev/null exit fi #Zenity asking SRM or ESDE #Opening RA/ESDE in background kill="ESDE" if [ "$(RetroArch_IsInstalled "$emuDeckEmuTypeFlatpak")" == "true" ]; then kill="RETROARCH" notify-send "RETROARCH" --icon="$HOME/.local/share/icons/emudeck/EmuDeck.png" --app-name "EmuDeck CloudSync" touch "$savesPath/.gaming" touch "$savesPath/.watching" echo "retroarch" > "$savesPath/.emuName" cloud_sync_startService systemctl --user is-active --quiet "EmuDeckCloudSync.service" status=$? if [ $status -eq 0 ]; then echo "CloudSync Service running" watcherStatus=0 else text="$(printf "CloudSync Error.\nCloudSync service is not running. Please reinstall CloudSync and try again")" zenity --error \ --title="EmuDeck" \ --width=400 \ --text="${text}" 2>/dev/null fi /usr/bin/flatpak run org.libretro.RetroArch & xdotool search --sync --name '^RetroArch$' windowminimize else zenity --question --title "CloudSync Health" --text "You need to have RetroArch installed for this to work." --cancel-label "Cancel" --ok-label "OK" if [ $? = 0 ]; then echo "continue" else zenity --info --width=400 --text="Please install RetroArch from Manage Emulators..." exit fi fi # #Testing Upload # #Creating new file echo "Creating test file" sleep 2 echo "testing upload" > "$savesPath/retroarch/test_emudeck.txt" #Upload should be happenning now in the background... while pgrep -x "rclone" > /dev/null; do echo "Waiting for cloudsync to finish..." sleep 5 done #"$cloud_sync_bin" --progress copyto -L --fast-list --checkers=50 --transfers=50 --low-level-retries 1 --retries 1 "$savesPath/test_emudeck.txt" "$cloud_sync_provider":"$cs_user"Emudeck/saves/.test_emudeck.txt #Check if the file exists in the cloud "$cloud_sync_bin" lsf "$cloud_sync_provider":"$cs_user"Emudeck/saves/retroarch/ | grep test_emudeck.txt status=$? # Evaluar el código de salida if [ $status -eq 0 ]; then echo "file exists in the cloud. SUCCESS" upload=0 else echo "file does not exist in the cloud. FAIL" fi #Delete local test file rm -rf "$savesPath/retroarch/test_emudeck.txt" # ##Testing Dowmload # #Downloading "$cloud_sync_bin" --progress copyto -L --fast-list --checkers=50 --transfers=50 --low-level-retries 1 --retries 1 "$cloud_sync_provider":"$cs_user"Emudeck/saves/retroarch/test_emudeck.txt "$savesPath/retroarch/test_emudeck.txt" #Check if the file exists. if [ -f "$savesPath/retroarch/test_emudeck.txt" ]; then echo "file exists in local. SUCCESS" download=0 else echo "file does not exist in local. FAIL" fi #Ending, closing loose ends rm -rf "$savesPath/.gaming" rm -rf "$savesPath/.watching" rm -rf "$savesPath/.emuName" rm -rf "$savesPath/retroarch/test_emudeck.txt" #Delete remote test file "$cloud_sync_bin" delete "$cloud_sync_provider":"$cs_user"Emudeck/saves/retroarch/test_emudeck.txt killall retroarch } > "$emudeckLogs/cloudHealth.log" echo "" echo "" #Check installation if [ ! -f "$cloud_sync_bin" ]; then echo "
Executable Status: Failure, please reinstall
" exit else echo "Executable Status: Success" fi echo "" if [ ! -f "$cloud_sync_config" ]; then echo "Config file Status: Failure, please reinstall" exit else echo "Config file Status: Success" fi echo "" if [ $cloud_sync_provider = '' ]; then echo "Provider Status: Failure, please reinstall" exit else echo "Provider Status: Success" fi echo "" if [ ! -d "$HOME/homebrew/plugins/EmuDecky" ]; then echo "EmuDecky Status: Failure, please install EmuDecky" >&2 return 1 else echo "EmuDecky Status: Success" fi echo "" if [ ! -f "$HOME/.config/systemd/user/EmuDeckCloudSync.service" ]; then echo "Watcher Status: Failure, please reinstall" exit else echo "Watcher Status: Installed" fi echo "" if [ $watcherStatus -eq 0 ]; then echo "CloudSync Service: Running" else echo "CloudSync Service: Not running" text="$(printf "CloudSync Service.\n CloudSync service was not detected. Please contact us on Patreon")" zenity --error \ --title="EmuDeck" \ --width=400 \ --text="${text}" 2>/dev/null fi echo "" # Tests upload echo "" if [ $upload -eq 0 ]; then echo "Upload Status: Success" elif [ $? = 2 ]; then echo "Save folder not found" else echo "Upload Status: Failure" fi echo "" # Tests download echo "" if [ $download -eq 0 ]; then echo "Download Status: Success" elif [ $? = 2 ]; then echo "Save folder not found" else echo "Download Status: Failure" fi echo "" echo "" echo "" cloud_sync_stopService }