Skip to content

Commit 3c5cb09

Browse files
committed
testing junction migration
1 parent f7b3604 commit 3c5cb09

File tree

1 file changed

+30
-101
lines changed

1 file changed

+30
-101
lines changed

functions/appImageInit.ps1

+30-101
Original file line numberDiff line numberDiff line change
@@ -2,118 +2,47 @@ function appImageInit(){
22

33
SRM_resetLaunchers
44

5-
#emudeck folder relocation
6-
$path = "$env:USERPROFILE/EmuDeck"
7-
if (Test-Path -Path $path -PathType Container) {
5+
#Emulators new Path Junction
6+
$carpetaA = "$env:USERPROFILE/EmuDeck/Emulators"
7+
$carpetaB = "$env:APPDATA/EmuDeck/Emulators"
88

9-
confirmDialog -TitleText "Migration" -MessageText "We are going to move the $env:USERPROFILE/EmuDeck folder to $env:APPDATA\EmuDeck.Please wait until a new message confirms the migration"
9+
# Verificar si la carpeta A es un directorio real
10+
$esDirectorioA = (Test-Path $carpetaA -PathType Container)
1011

11-
$destination = "$env:APPDATA/EmuDeck"
12+
# Verificar si la carpeta B no existe o si existe pero no es un Junction
13+
$existeB = Test-Path $carpetaB -PathType Container
14+
$esJunctionB = $false
1215

13-
$originalFolderName = Split-Path $path -Leaf
14-
$newFolderName = Split-Path $destination -Leaf
15-
16-
Get-ChildItem -Path "$path" | ForEach-Object {
17-
$destinationPath = Join-Path -Path $destination -ChildPath $_.Name
18-
if (-Not (Test-Path -Path $destinationPath)) {
19-
Write-Host "Moving: $_.FullName to $destination" -ForegroundColor Blue
20-
Move-Item -Path $_.FullName -Destination $destination
21-
} else {
22-
Write-Host "El elemento ya existe en el destino: $destinationPath" -ForegroundColor Yellow
23-
}
24-
}
25-
26-
#createSaveLink $path "$env:APPDATA\EmuDeck\"
27-
28-
. "$env:APPDATA/EmuDeck/settings.ps1"
29-
. "$env:APPDATA/EmuDeck/backend/vars.ps1"
30-
31-
32-
SRM_createParsers
33-
ESDE_init
34-
35-
Remove-Item -Path $path -Recurse -Force
36-
37-
$folders = Get-ChildItem -Path ("$steamInstallPath\userdata") -Director
38-
39-
foreach ($folder in $folders) {
40-
41-
$filePath = "$steamInstallPath\userdata\$folder\config\shortcuts.vdf"
42-
if (Test-Path -Path "$filePath") {
43-
44-
$shorcutsPath = "$filePath"
45-
}
46-
}
47-
Copy-Item "$shorcutsPath" -Destination "$shorcutsPath.baknew" -ErrorAction SilentlyContinue
48-
$filePath = "$shorcutsPath"
49-
$content = Get-Content -Raw -Encoding Default $filePath
50-
$newContent = $content -replace [regex]::Escape("EmuDeck\Emulators"), "AppData\Roaming\EmuDeck\Emulators"
51-
$newContent = $newContent -replace [regex]::Escape("EmuDeck\EmulationStation-DE\Emulators"), "AppData\Roaming\EmuDeck\Emulators"
52-
Set-Content -Path $filePath -Value $newContent -Encoding Default
53-
54-
confirmDialog -TitleText "Complete" -MessageText "Migration complete,you can now use EmuDeck as always. The Emulation folder is still at $emulationPath"
55-
}
56-
57-
# Copy-Item "$shorcutsPath" -Destination "$shorcutsPath.bak" -ErrorAction SilentlyContinue
58-
59-
60-
$folders = Get-ChildItem -Path ("$steamInstallPath\userdata") -Director
61-
62-
foreach ($folder in $folders) {
63-
64-
$filePath = "$steamInstallPath\userdata\$folder\config\shortcuts.vdf.bak"
65-
if (Test-Path -Path "$filePath") {
66-
$shorcutsPath = "$filePath"
67-
$result = yesNoDialog -TitleText "SRM Backup" -MessageText "Is your Steam Library corrupted? Do you want to restore your last backup?" -OKButtonText "Yes" -CancelButtonText "No"
68-
69-
if ($result -eq "OKButton") {
70-
$steamRunning = Get-Process -Name "Steam" -ErrorAction SilentlyContinue
71-
if ($steamRunning) {
72-
taskkill /IM steam.exe /F
73-
}
74-
Rename-Item -Path "$steamInstallPath\userdata\$folder\config\shortcuts.vdf" -NewName "$steamInstallPath\userdata\$folder\config\shortcuts.vdf.bak2"
75-
Copy-Item "$shorcutsPath" -Destination "$steamInstallPath\userdata\$folder\config\shortcuts.vdf" -ErrorAction SilentlyContinue
76-
Rename-Item -Path "$shorcutsPath" -NewName "$shorcutsPath.restored"
77-
78-
79-
}else{
80-
Rename-Item -Path "$shorcutsPath" -NewName "$shorcutsPath.cancel"
81-
}
16+
if ($existeB) {
17+
$esJunctionB = (Get-Item $carpetaB).Attributes -match "ReparsePoint"
18+
}
8219

83-
}
84-
}
20+
# Si la carpeta A es un directorio y la carpeta B no existe o no es un junction, ejecutar pepito
21+
if ($esDirectorioA -and (-not $existeB -or -not $esJunctionB)) {
22+
createSaveLink $carpetaA $carpetaB
23+
}
8524

86-
$folders = Get-ChildItem -Path ("$steamInstallPath\userdata") -Director
25+
#ESDE new Path Junction
26+
$carpetaA = "$env:USERPROFILE/EmuDeck/EmulationStation-DE"
27+
$carpetaB = "$env:APPDATA/EmuDeck/EmulationStation-DE"
8728

88-
foreach ($folder in $folders) {
29+
# Verificar si la carpeta A es un directorio real
30+
$esDirectorioA = (Test-Path $carpetaA -PathType Container)
8931

90-
$filePath = "$steamInstallPath\userdata\$folder\config\shortcuts.vdf"
91-
if (Test-Path -Path "$filePath") {
32+
# Verificar si la carpeta B no existe o si existe pero no es un Junction
33+
$existeB = Test-Path $carpetaB -PathType Container
34+
$esJunctionB = $false
9235

93-
$shorcutsPath = "$filePath"
94-
}
95-
}
96-
Copy-Item "$shorcutsPath" -Destination "$shorcutsPath.baknew" -ErrorAction SilentlyContinue
97-
$filePath = "$shorcutsPath"
98-
$content = Get-Content -Raw -Encoding Default $filePath
99-
$newContent = $content -replace [regex]::Escape("EmuDeck\Emulators"), "AppData\Roaming\EmuDeck\Emulators"
100-
$newContent = $newContent -replace [regex]::Escape("EmuDeck\EmulationStation-DE\Emulators"), "AppData\Roaming\EmuDeck\Emulators"
101-
$newContent = $newContent -replace [regex]::Escape("AppData\Roaming\AppData\Roaming"), "AppData\Roaming"
102-
Set-Content -Path $filePath -Value $newContent -Encoding Default
36+
if ($existeB) {
37+
$esJunctionB = (Get-Item $carpetaB).Attributes -match "ReparsePoint"
38+
}
10339

104-
$path = "$esdePath/Emulators"
105-
if (Test-Path -Path $path -PathType Container) {
106-
$item = Get-Item $path
107-
if ($item.Attributes -band [System.IO.FileAttributes]::ReparsePoint) {
108-
Write-Output "$path it's a junction."
109-
} else {
110-
Write-Output "$path it's a directory."
111-
Move-Item -Path $path -Destination $emusPath
112-
createSaveLink $path $emusPath
113-
SRM_resetLaunchers
114-
}
40+
# Si la carpeta A es un directorio y la carpeta B no existe o no es un junction, ejecutar pepito
41+
if ($esDirectorioA -and (-not $existeB -or -not $esJunctionB)) {
42+
createSaveLink $carpetaA $carpetaB
11543
}
11644

45+
11746
#AutoFixes
11847
mkdir "$emudeckFolder/feeds" -ErrorAction SilentlyContinue
11948

0 commit comments

Comments
 (0)