-
Notifications
You must be signed in to change notification settings - Fork 20
/
cloudSyncHealth.ps1
471 lines (410 loc) · 12.6 KB
/
cloudSyncHealth.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
. $env:APPDATA\EmuDeck\backend\functions\all.ps1
cls
$upload="Yes"
$download="Yes"
"" | Set-Content "$userFolder/EmuDeck/logs/rclone.log" -Encoding UTF8
Write-Host "Testing EmuDeck integrity..." -ForegroundColor White
if ( ! $userFolder ){
cls
Write-Host "We can't find your installation" -ForegroundColor Red
Write-Host "Open an Issue in our discord and upload this file: $env:USERPROFILE\emudeck\settings.ps1" -ForegroundColor Red
Read-Host -Prompt "Press any key to continue or CTRL+C to quit"
exit
}
if ( "$env:APPDATA\EmuDeck\backend\functions\allCloud.ps1" -like "NYI*"){
confirmDialog -TitleText "Corrupted installation" -MessageText "EmuDeck will reinstall after clicking OK, nothing will be deleted. This could take a while"
cls
Write-Host "Downloading EmuDeck..." -ForegroundColor Cyan
$url_emudeck = getLatestReleaseURLGH 'EmuDeck/emudeck-electron-early' 'exe' 'emudeck'
download $url_emudeck "emudeck_install.exe"
&"$temp/emudeck_install.exe"
cls
Write-Host "Please open CloudSyncHealth again after the reinstallation of EmuDeck has finished" -ForegroundColor Cyan
break
exit
}
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"
Write-Host "Testing $emuName download..."
& $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`:$cs_user`Emudeck\saves\$emuName\.temp" "$fileHash"
if ($?) {
Write-Host "success" -ForegroundColor Green
}else{
Write-Host "failure" -ForegroundColor Red
$download="No"
}
rm -fo -r "$target\.temp" -ErrorAction SilentlyContinue
}else{
Write-Host "$emuName not installed" -ForegroundColor Yellow
}
}
}
function cloud_sync_upload_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"
Write-Host "Testing $emuName upload..."
& $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`:$cs_user`Emudeck\saves\$emuName\.temp"
if ($?) {
Write-Host "success" -ForegroundColor Green
}else{
Write-Host "failure" -ForegroundColor Red
$upload="No"
}
rm -fo -r "$target\.temp" -ErrorAction SilentlyContinue
}else{
Write-Host "$emuName not installed" -ForegroundColor Yellow
}
}
}
cls
Write-Host "Generating CloudSync Status Report..." -ForegroundColor DarkCyan
Write-Host ""
$subcarpetas = Get-ChildItem "$emusPath" -Directory -Recurse
$resultadosSL = @()
###
###
### Do we have symlinks in the emulators?
###
###
foreach ($subcarpeta in $subcarpetas) {
$symlinks = Get-ChildItem -Path $subcarpeta.FullName -Attributes ReparsePoint
if ($symlinks.Count -gt 0) {
$resultadosSL += $subcarpeta.FullName
}
}
$textoABuscarduckstation="duckstation"
$textoABuscarPCSX2="PCSX2-Qt"
$textoABuscarRetroArch="RetroArch"
$textoABuscarcemu="cemu\mlc01\usr"
$textoABuscarcitra="citra\user"
$textoABuscarDolphin="Dolphin-x64\User"
$textoABuscarPPSSPP="PPSSPP\memstick\PSP"
$textoABuscarRyujinx="Ryujinx\portable\bis\user"
$textoABuscaryuzu="yuzu\yuzu-windows-msvc\user\nand\user"
$textoABuscaryuzu2="yuzu-windows-msvc\user\nand\system\save\8000000000000010\su"
$duckstationSL="No"
$pcsx2SL="No"
$retroarchSL="No"
$cemuSL="No"
$citraSL="No"
$dolphinSL="No"
$ppssppSL="No"
$ryujinxSL="No"
$yuzuSL="No"
## rpcs3 special case
$subcarpetas = Get-ChildItem "$storagePath/rpcs3" -Directory -Recurse
$rpcs3SL = "No"
foreach ($subcarpeta in $subcarpetas) {
$symlinks = Get-ChildItem -Path $subcarpeta.FullName -Attributes ReparsePoint
if ($symlinks.Count -gt 0) {
$rpcs3SL = "Yes"
}
}
if ($resultadosSL.Count -gt 0) {
$resultadosSL | ForEach-Object {
if ($_ -like "*$textoABuscarduckstation*"){
$duckstationSL="Yes"
}
if ($_ -like "*$textoABuscarPCSX2*"){
$pcsx2SL="Yes"
}
if ($_ -like "*$textoABuscarRetroArch*"){
$retroarchSL="Yes"
}
if ($_ -like "*$textoABuscarcemu*"){
$cemuSL="Yes"
}
if ($_ -like "*$textoABuscarcitra*"){
$citraSL="Yes"
}
if ($_ -like "*$textoABuscarDolphin*"){
$dolphinSL="Yes"
}
if ($_ -like "*$textoABuscarPPSSPP*"){
$ppssppSL="Yes"
}
if ($_ -like "*$textoABuscarRyujinx*"){
$ryujinxSL="Yes"
}
if ($_ -like "*$textoABuscaryuzu*"){
$yuzuSL="Yes"
}else{
$yuzuSL="No"
}
if ($_ -like "*$textoABuscaryuzu2*"){
$yuzuSL="Yes"
}else{
$yuzuSL="No"
}
}
}
###
###
### Are the folders in Emulations/saves Folders or are lnk same with internal emulators?
###
###
$lnkFiles="No"
foreach ($subcarpeta in $subcarpetas) {
$archivoslnk = Get-ChildItem -Path $subcarpeta.FullName -Filter *.lnk
if ($archivoslnk.Count -gt 0) {
foreach ($archivo in $archivoslnk) {
Remove-Item $archivo.FullName
}
$lnkFiles="Yes"
break
}else{
$lnkFiles="No"
}
}
$subcarpetasSaves = Get-ChildItem $savesPath -Directory -Recurse
$lnkFilesSaves="No"
foreach ($subcarpeta in $subcarpetasSaves) {
$archivoslnk = Get-ChildItem -Path $subcarpeta.FullName -Filter *.lnk
if ($archivoslnk.Count -gt 0) {
foreach ($archivo in $archivoslnk) {
Remove-Item $archivo.FullName
}
$lnkFilesSaves="Yes"
break
}else{
$lnkFilesSaves="No"
}
}
$lnkFilesSaves2="No"
$carpetasNoDirectorio = @()
foreach ($subcarpeta in $subcarpetasSaves) {
if (-not (Test-Path -Path $subcarpeta.FullName -PathType Container)) {
$carpetasNoDirectorio += $subcarpeta.FullName
}
}
if ($carpetasNoDirectorio.Count -gt 0) {
$lnkFilesSaves2="No"
} else {
$lnkFilesSaves2="Yes"
}
###
###
### Is there a rclone.conf?
###
###
$rcloneConf = "No"
if (Test-Path "$toolsPath\rclone\rclone.conf") {
$rcloneConf = "Yes"
}
###
###
### Are the parsers updated?
###
###
$steamRegPath = "HKCU:\Software\Valve\Steam"
$steamInstallPath = (Get-ItemProperty -Path $steamRegPath).SteamPath
$steamInstallPath = $steamInstallPath.Replace("/", "\\")
$steamPath = "$steamInstallPath\userdata"
# Busca el archivo shortcuts.vdf en cada carpeta de userdata
$parsersUpdated="Yes"
$archivosLinksVDF = Get-ChildItem -Path $steamPath -File -Recurse -Filter "shortcuts.vdf"
if ($archivosLinksVDF.Count -gt 0) {
$archivosLinksVDF | ForEach-Object {
$filePath = $_.FullName
$shortcutsContent = Get-Content -Path $filePath
if ($shortcutsContent -like "*.bat*"){
$parsersUpdated="No"
}
}
}
###
###
### are the functions loaded??
###
###
$cloudFunc="No"
if ( "$env:APPDATA\EmuDeck\backend\functions\allCloud.ps1" -like "*AppData*"){
$cloudFunc="Yes"
}
cls
Write-Host "CloudSync Status Report" -ForegroundColor white
Write-Host ""
#### shortcuts
Write-Host "Is EmuDeck using old shortcuts (.lnk) for the save folders inside C:\Users\REDACTED\EmuDeck\EmulationStation-DE\Emulators?" -ForegroundColor DarkYellow
if ( $lnkFiles -eq "Yes" ){
$color = "Red"
}else{
$color = "Green"
}
Write-Host $lnkFiles -ForegroundColor $color
Write-Host ""
Write-Host "Is EmuDeck using old shortcuts (.lnk) for the save folders inside ${savesPath}?" -ForegroundColor DarkYellow
if ( $lnkFilesSaves -eq "Yes" ){
$color = "Red"
}else{
$color = "Green"
}
Write-Host $lnkFilesSaves -ForegroundColor $color
Write-Host ""
Write-Host "Are there proper folders inside ${savesPath}?" -ForegroundColor DarkYellow
if ( $lnkFilesSaves2 -eq "Yes" ){
$color = "Green"
}else{
$color = "Red"
}
Write-Host $lnkFilesSaves2 -ForegroundColor $color
if ($carpetasNoDirectorio.Count -gt 0) {
Write-Host "Wrong folders:"
$carpetasNoDirectorio | ForEach-Object {
Write-Host $_
}
}
Write-Host ""
Write-Host "Is EmuDeck using the new symlinks for the save folders inside C:\Users\REDACTED\EmuDeck\EmulationStation-DE\Emulators?" -ForegroundColor DarkYellow
$setupSaves=''
if ($duckstationSL -eq "Yes"){
$color1 ="Green"
}else{
$color1 = "Red"
$setupSaves+="DuckStation_setupSaves;"
}
if ($pcsx2SL -eq "Yes"){
$color2 ="Green"
}else{
$color2 = "Red"
$setupSaves+="PCSX2QT_setupSaves;"
}
if ($rpcs3SL -eq "Yes"){
$color3 ="Green"
}else{
$color3 = "Red"
$setupSaves+="RPCS3_setupSaves;"
}
if ($retroarchSL -eq "Yes"){
$color4 ="Green"
}else{
$color4 = "Red"
RetroArch_init
$setupSaves+="RetroArch_setupSaves;"
}
if ($cemuSL -eq "Yes"){
$color5 ="Green"
}else{
$color5 = "Red"
$setupSaves+="Cemu_setupSaves;"
}
if ($citraSL -eq "Yes"){
$color6 ="Green"
}else{
$color6 = "Red"
$setupSaves+="Citra_setupSaves;"
}
if ($dolphinSL -eq "Yes"){
$color7 ="Green"
}else{
$color7 = "Red"
$setupSaves+="Dolphin_setupSaves;"
}
if ($ppssppSL -eq "Yes"){
$color8 ="Green"
}else{
$color8 = "Red"
$setupSaves+="PPSSPP_setupSaves;"
}
if ($ryujinxSL -eq "Yes"){
$color9 ="Green"
}else{
$color9 = "Red"
$setupSaves+="Ryujinx_setupSaves;"
}
if ($yuzuSL -eq "Yes"){
$color10 ="Green"
}else{
$color10 = "Red"
$setupSaves+="Yuzu_setupSaves;"
}
Write-Host "duckstation: $duckstationSL" -ForegroundColor $color1
Write-Host "pcsx2: $pcsx2SL" -ForegroundColor $color2
Write-Host "rpcs3: $rpcs3SL" -ForegroundColor $color3
Write-Host "retroarch: $retroarchSL" -ForegroundColor $color4
Write-Host "cemu: $cemuSL" -ForegroundColor $color5
Write-Host "citra: $citraSL" -ForegroundColor $color6
Write-Host "dolphin: $dolphinSL" -ForegroundColor $color7
Write-Host "ppsspp: $ppssppSL" -ForegroundColor $color8
Write-Host "ryujinx: $ryujinxSL" -ForegroundColor $color9
Write-Host "yuzu: $yuzuSL" -ForegroundColor $color10
Write-Host ""
echo $setupSaves;
if( $setupSaves -ne '' ){
Write-Host "Trying to fix Symlinks..." -ForegroundColor DarkYellow
$setupSaves = $setupSaves.Substring(0, $setupSaves.Length - 1)
Invoke-Expression $setupSaves
Write-Host ""
}
Write-Host "Are CloudSync functions installed?" -ForegroundColor DarkYellow
if ($cloudFunc -eq "Yes"){
$color ="Green"
}else{
$color = "Red"
}
Write-Host "$cloudFunc" -ForegroundColor $color
Write-Host ""
Write-Host "Has a cloudSync config file?" -ForegroundColor DarkYellow
if ($rcloneConf -eq "Yes"){
$color ="Green"
}else{
$color = "Red"
confirmDialog -TitleText "CloudSync not installed" -MessageText "Please Open EmuDeck and install it"
break
exit
}
Write-Host "$rcloneConf" -ForegroundColor $color
Write-Host ""
Write-Host "Is cloudSync installed?" -ForegroundColor DarkYellow
if (Test-Path "$cloud_sync_bin"){
Write-Host "$cloudFunc" -ForegroundColor "Green"
}else{
Write-Host "$cloudFunc" -ForegroundColor "Red"
confirmDialog -TitleText "CloudSync not installed" -MessageText "Please Open EmuDeck and install it"
break
exit
}
Write-Host ""
Write-Host "Are the SRM parsers updated?" -ForegroundColor DarkYellow
if ($parsersUpdated -eq "Yes"){
$color ="Green"
}else{
$color = "Red"
}
Write-Host "$parsersUpdated" -ForegroundColor $color
Write-Host ""
$miArreglo = @("yuzu","Cemu","citra","dolphin","duckstation","es-de","melonds","pcsx2","ppsspp","retroarch","rpcs3","ryujinx")
Write-Host "Testing uploading" -ForegroundColor DarkYellow
foreach ($elemento in $miArreglo) {
cloud_sync_upload_test $elemento
}
Write-Host ""
Write-Host "Testing downloading" -ForegroundColor DarkYellow
foreach ($elemento in $miArreglo) {
cloud_sync_download_test $elemento
}
Write-Host ""
Write-Host ""
Write-Host "Recomendations..." -ForegroundColor DarkCyan
if($lnkFiles -eq "Yes" -or $lnkFiles2 -eq "Yes"){
Write-Host "We've cleaned up your old .lnk files but make sure you don't have .lnk files in your cloud provider, delete them if you do" -ForegroundColor Yellow
}
if ($lnkFiles -eq "Yes" -or $lnkFilesSaves -eq "Yes" -or $lnkFilesSaves2 -eq "No" -or $rcloneConf -eq "No" -or $duckstationSL -eq "No" -or $pcsx2SL -eq "No" -or $retroarchSL -eq "No" -or $cemuSL -eq "No" -or $citraSL -eq "No" -or $dolphinSL -eq "No" -or $ppssppSL -eq "No" -or $ryujinxSL -eq "No" -or $yuzuSL -eq "No") {
Write-Host "Do a Custom Reset" -ForegroundColor Yellow
}elseif($download -eq "No" -or $upload -eq "No" ){
Write-Host "Reinstall CloudSync" -ForegroundColor Yellow
}elseif($parsersUpdated -eq "No"){
Write-Host "Open EmuDeck, go to Manage Emulators and reset Steam Rom Manager Configuration. Then open Steam Rom Manager and parse all your games again to get the proper launchers" -ForegroundColor Yellow
}elseif($cloudFunc -eq "No"){
Write-Host "Open EmuDeck, check that in the top right you have a yellow triangle that says EARLY" -ForegroundColor Yellow
}else{
Write-Host "Everything seems to be in proper order, at least on Windows" -ForegroundColor Yellow
}
waitForUser