diff --git a/FAQ.md b/FAQ.md index 6197c46d8..e046abb16 100644 --- a/FAQ.md +++ b/FAQ.md @@ -697,6 +697,16 @@ known), per profile ("Console" is the console's own save), with Back up now and put one back, close ProsperoEden and press Restore on the version you want; the save there now is backed up first. A restore is refused while ProsperoEden runs. +EglantinePS5 (PPSA98515) is included too. Its saves stay in +`/data/eglantineps5/user/nand/user/save/0000000000000000///`, +regardless of where its games are kept. Each profile and game's folder is backed up by the same +local, console-drive and server passes, including after EglantinePS5 closes. Save Data lists them +in their own “Switch / Switch 2 games (EglantinePS5)” group. A restore waits for EglantinePS5 to close and +backs up the save there first. Its backups have their own profile numbers, so +copies of the same game and profile in ProsperoEden stay separate, including retention. The +profile label still shows the emulator's profile, and older ProsperoEden backup names stay valid. + + The saves of the PS2 emulators Crux2 (PPSA99249) and PS5SX2 (PPSA99203) are backed up the same way, after the emulator closes: its memory cards folder and its saved states folder, each as one save under the emulator's own title ID (user 0 the cards, user 1 the saved states). Crux2 keeps diff --git a/client/e2e/switch-saves.spec.ts b/client/e2e/switch-saves.spec.ts index d5278719a..f1ad95841 100644 --- a/client/e2e/switch-saves.spec.ts +++ b/client/e2e/switch-saves.spec.ts @@ -129,3 +129,30 @@ test("Saves shows no Switch group when ProsperoEden has no saves", async ({ page await expect(page.locator('[data-title-id="PPSA01234"]')).toBeVisible({ timeout: 30_000 }); await expect(page.getByTestId("switch-saves")).toHaveCount(0); }); + + +test("Eglantine and Eden show independent groups and backup histories", async ({ page }) => { + const eglantineRoot = "/data/eglantineps5/user/nand/user/save/0000000000000000"; + const saves = [ + { title_id: GAME, user_id: 0x01f1e1d1, path: `${ROOT}/${PROFILE}/${GAME}`, size: 17, mtime: 1761800000, kind: "switch", emulator: "ProsperoEden", running: true }, + { title_id: GAME, user_id: 0x11f1e1d1, path: `${eglantineRoot}/${PROFILE}/${GAME}`, size: 20, mtime: 1761800000, kind: "switch", emulator: "EglantinePS5", running: false }, + { title_id: GAME, user_id: 0x10000000, path: `${eglantineRoot}/${"0".repeat(32)}/${GAME}`, size: 3, mtime: 1761800000, kind: "switch", emulator: "EglantinePS5", running: false }, + ]; + const { handler } = mockEngine(saves, true); + await page.addInitScript((h) => window.localStorage.setItem("ps5upload.host", h), HOST); + await page.route((url) => url.pathname.startsWith("/api/"), handler); + await page.goto("/saves", { waitUntil: "domcontentloaded" }); + const eden = page.locator('[data-testid="switch-saves"][data-emulator="ProsperoEden"]'); + const eglantine = page.locator('[data-testid="switch-saves"][data-emulator="EglantinePS5"]'); + await expect(eglantine.getByRole("heading", { name: "Switch / Switch 2 games (EglantinePS5)" })).toBeVisible({ timeout: 30_000 }); + await expect(eglantine.getByText("Switch / Switch 2", { exact: true })).toBeVisible(); + await expect(eden.getByTestId("switch-saves-note")).toHaveText("ProsperoEden is running. Close it before restoring."); + await expect(eglantine.getByTestId("switch-saves-note")).toHaveText("Close EglantinePS5 before restoring."); + const rows = eglantine.getByTestId("switch-save"); + await expect(rows.nth(0)).toContainText("Profile 1F1E1D1"); + await expect(rows.nth(1)).toContainText("Console"); + // Eden's backup of the exact same game and profile must not appear under Eglantine. + await expect(eden.getByRole("button", { name: "Restore", exact: true })).toHaveCount(1); + await expect(eglantine.getByRole("button", { name: "Restore", exact: true })).toHaveCount(0); + await expect(rows.nth(0)).toContainText("No backups yet."); +}); diff --git a/client/src/api/saveBackup.ts b/client/src/api/saveBackup.ts index ee6d09956..55b75f5de 100644 --- a/client/src/api/saveBackup.ts +++ b/client/src/api/saveBackup.ts @@ -322,8 +322,8 @@ export const saveFoldersApi = { call<{ ok: boolean }>("/folders/restore", { ...LONG, method: "POST", body: JSON.stringify(req) }), }; -/** A save of ProsperoEden, the Switch emulator (PPSA99008): `title_id` is the game's 16-hex-digit - * title ID and `user_id` its profile's first 7 hex digits (0 for the console's own save). */ +/** A Switch emulator's per-game save. `user_id` keeps the profile's first 7 hex digits + * in its lower 28 bits; bit 28 separates EglantinePS5 backups from ProsperoEden. */ export interface SwitchSave { title_id: string; user_id: number; @@ -331,7 +331,9 @@ export interface SwitchSave { size: number; mtime: number; kind: "switch"; - /** ProsperoEden runs now; null when the console did not say. */ + /** Omitted by engines that only know ProsperoEden. */ + emulator?: string; + /** This save's emulator runs now; null when the console did not say. */ running: boolean | null; } @@ -405,7 +407,7 @@ export const saveBackupApi = { /** The newest backup of each game and user in the backup folder. */ latest: async () => (await call<{ latest: Array<{ title_id: string; user_id: number; stamp: string }> }>("/latest")).latest, - /** ProsperoEden's saves on a console (bare IP): none when it is not installed. */ + /** Switch emulators' saves on a console (bare IP): none when neither has saved. */ switchSaves: (addr: string) => call<{ saves: SwitchSave[]; running: boolean | null }>(`/switch?addr=${encodeURIComponent(addr)}`), /** The PlayStation 2 emulators' and PSSwanStation's cards and saved states on a console (bare diff --git a/client/src/i18n/locales/ar.ts b/client/src/i18n/locales/ar.ts index 3508f3f5b..1cb3b2a60 100644 --- a/client/src/i18n/locales/ar.ts +++ b/client/src/i18n/locales/ar.ts @@ -7696,10 +7696,10 @@ helper_copies_failed_body: "لا يزال المساعد القديم: {list}. "rp_keyboard_hint": "Enter: تم. Esc: إلغاء. أثناء الكتابة هنا لا تصل أي مفاتيح أو ضغطات من وحدة التحكم إلى اللعبة.", "rp_settings_paused": "لا تصل أي مفاتيح أو ضغطات من وحدة التحكم إلى اللعبة ما دامت الإعدادات مفتوحة.", "rp_picture_tools": "أدوات الصورة", - "saves_switch_title": "ألعاب Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden يعمل. أغلقه قبل الاستعادة.", - "saves_switch_close_note": "أغلق ProsperoEden قبل الاستعادة.", - "saves_switch_badge": "Switch", + "saves_switch_title": "ألعاب {platform} ({emulator})", + "saves_switch_running": "{emulator} يعمل. أغلقه قبل الاستعادة.", + "saves_switch_close_note": "أغلق {emulator} قبل الاستعادة.", + "saves_switch_badge": "{platform}", "saves_switch_console": "الجهاز", "saves_switch_profile": "الملف الشخصي {id}", "saves_switch_changed": "آخر تغيير {when}", diff --git a/client/src/i18n/locales/bn.ts b/client/src/i18n/locales/bn.ts index 142abeab5..355b018bd 100644 --- a/client/src/i18n/locales/bn.ts +++ b/client/src/i18n/locales/bn.ts @@ -7696,10 +7696,10 @@ helper_copies_failed_body: "এখনও পুরোনো হেল্পা "rp_keyboard_hint": "Enter: হয়ে গেছে। Esc: বাতিল। আপনি এখানে টাইপ করার সময় গেম কোনো কী বা কন্ট্রোলার চাপ পায় না।", "rp_settings_paused": "সেটিংস খোলা থাকাকালীন গেম কোনো কী বা কন্ট্রোলারের চাপ পায় না।", "rp_picture_tools": "ছবির টুল", - "saves_switch_title": "Switch গেম (ProsperoEden)", - "saves_switch_running": "ProsperoEden চলছে। রিস্টোর করার আগে এটি বন্ধ করুন।", - "saves_switch_close_note": "রিস্টোর করার আগে ProsperoEden বন্ধ করুন।", - "saves_switch_badge": "Switch", + "saves_switch_title": "{platform} গেম ({emulator})", + "saves_switch_running": "{emulator} চলছে। রিস্টোর করার আগে এটি বন্ধ করুন।", + "saves_switch_close_note": "রিস্টোর করার আগে {emulator} বন্ধ করুন।", + "saves_switch_badge": "{platform}", "saves_switch_console": "কনসোল", "saves_switch_profile": "প্রোফাইল {id}", "saves_switch_changed": "শেষ পরিবর্তন {when}", diff --git a/client/src/i18n/locales/de.ts b/client/src/i18n/locales/de.ts index da93ad2cc..095acea4e 100644 --- a/client/src/i18n/locales/de.ts +++ b/client/src/i18n/locales/de.ts @@ -7704,10 +7704,10 @@ helper_copies_failed_body: "Weiterhin der alte Helfer: {list}. Die PS5 startet i "rp_keyboard_hint": "Enter: fertig. Esc: abbrechen. Während du hier tippst, bekommt das Spiel keine Tasten und keine Controller-Eingaben.", "rp_settings_paused": "Solange die Einstellungen offen sind, bekommt das Spiel keine Tasten und keine Controller-Eingaben.", "rp_picture_tools": "Bildwerkzeuge", - "saves_switch_title": "Switch-Spiele (ProsperoEden)", - "saves_switch_running": "ProsperoEden läuft. Schließe es vor dem Wiederherstellen.", - "saves_switch_close_note": "Schließe ProsperoEden vor dem Wiederherstellen.", - "saves_switch_badge": "Switch", + "saves_switch_title": "{platform}-Spiele ({emulator})", + "saves_switch_running": "{emulator} läuft. Schließe es vor dem Wiederherstellen.", + "saves_switch_close_note": "Schließe {emulator} vor dem Wiederherstellen.", + "saves_switch_badge": "{platform}", "saves_switch_console": "Konsole", "saves_switch_profile": "Profil {id}", "saves_switch_changed": "Zuletzt geändert {when}", diff --git a/client/src/i18n/locales/en.ts b/client/src/i18n/locales/en.ts index a8f063c11..6926faba1 100644 --- a/client/src/i18n/locales/en.ts +++ b/client/src/i18n/locales/en.ts @@ -8005,10 +8005,10 @@ helper_copies_failed_body: "Still the old helper: {list}. The PS5 starts it agai "rp_keyboard_hint": "Enter: done. Esc: cancel. While you type here, the game gets no keys or controller presses.", "rp_settings_paused": "The game gets no keys or controller presses while Settings is open.", "rp_picture_tools": "Picture tools", - "saves_switch_title": "Switch games (ProsperoEden)", - "saves_switch_running": "ProsperoEden is running. Close it before restoring.", - "saves_switch_close_note": "Close ProsperoEden before restoring.", - "saves_switch_badge": "Switch", + "saves_switch_title": "{platform} games ({emulator})", + "saves_switch_running": "{emulator} is running. Close it before restoring.", + "saves_switch_close_note": "Close {emulator} before restoring.", + "saves_switch_badge": "{platform}", "saves_switch_console": "Console", "saves_switch_profile": "Profile {id}", "saves_switch_changed": "Last changed {when}", diff --git a/client/src/i18n/locales/es.ts b/client/src/i18n/locales/es.ts index 09af27d77..fc3eb7e08 100644 --- a/client/src/i18n/locales/es.ts +++ b/client/src/i18n/locales/es.ts @@ -7649,10 +7649,10 @@ helper_copies_failed_body: "Sigue siendo el ayudante antiguo: {list}. La PS5 lo "rp_keyboard_hint": "Intro: listo. Esc: cancelar. Mientras escribes aquí, el juego no recibe teclas ni pulsaciones del mando.", "rp_settings_paused": "El juego no recibe teclas ni pulsaciones del mando mientras los ajustes están abiertos.", "rp_picture_tools": "Herramientas de imagen", - "saves_switch_title": "Juegos de Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden está abierto. Ciérralo antes de restaurar.", - "saves_switch_close_note": "Cierra ProsperoEden antes de restaurar.", - "saves_switch_badge": "Switch", + "saves_switch_title": "Juegos de {platform} ({emulator})", + "saves_switch_running": "{emulator} está abierto. Ciérralo antes de restaurar.", + "saves_switch_close_note": "Cierra {emulator} antes de restaurar.", + "saves_switch_badge": "{platform}", "saves_switch_console": "Consola", "saves_switch_profile": "Perfil {id}", "saves_switch_changed": "Último cambio {when}", diff --git a/client/src/i18n/locales/fa.ts b/client/src/i18n/locales/fa.ts index 3ac64a493..2e45c5f77 100644 --- a/client/src/i18n/locales/fa.ts +++ b/client/src/i18n/locales/fa.ts @@ -7974,10 +7974,10 @@ helper_copies_failed_body: "هنوز کمک‌یار قدیمی است: {list}. "rp_keyboard_hint": "Enter: تمام. Esc: لغو. تا وقتی اینجا تایپ می‌کنید، بازی هیچ کلید یا فشار دسته‌ای دریافت نمی‌کند.", "rp_settings_paused": "تا وقتی تنظیمات باز است، بازی هیچ کلید یا فشار دسته‌ای دریافت نمی‌کند.", "rp_picture_tools": "ابزارهای تصویر", - "saves_switch_title": "بازی‌های Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden در حال اجراست. پیش از بازیابی آن را ببندید.", - "saves_switch_close_note": "پیش از بازیابی ProsperoEden را ببندید.", - "saves_switch_badge": "Switch", + "saves_switch_title": "بازی‌های {platform} ({emulator})", + "saves_switch_running": "{emulator} در حال اجراست. پیش از بازیابی آن را ببندید.", + "saves_switch_close_note": "پیش از بازیابی {emulator} را ببندید.", + "saves_switch_badge": "{platform}", "saves_switch_console": "کنسول", "saves_switch_profile": "پروفایل {id}", "saves_switch_changed": "آخرین تغییر {when}", diff --git a/client/src/i18n/locales/fr.ts b/client/src/i18n/locales/fr.ts index b5d53c496..3acc7974a 100644 --- a/client/src/i18n/locales/fr.ts +++ b/client/src/i18n/locales/fr.ts @@ -7712,10 +7712,10 @@ helper_copies_failed_body: "Toujours l'ancien assistant : {list}. La PS5 le rela "rp_keyboard_hint": "Entrée : terminé. Échap : annuler. Pendant la saisie ici, le jeu ne reçoit ni touches ni appuis de manette.", "rp_settings_paused": "Le jeu ne reçoit ni touches ni appuis de manette tant que les réglages sont ouverts.", "rp_picture_tools": "Outils d'image", - "saves_switch_title": "Jeux Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden est ouvert. Fermez-le avant de restaurer.", - "saves_switch_close_note": "Fermez ProsperoEden avant de restaurer.", - "saves_switch_badge": "Switch", + "saves_switch_title": "Jeux {platform} ({emulator})", + "saves_switch_running": "{emulator} est ouvert. Fermez-le avant de restaurer.", + "saves_switch_close_note": "Fermez {emulator} avant de restaurer.", + "saves_switch_badge": "{platform}", "saves_switch_console": "Console", "saves_switch_profile": "Profil {id}", "saves_switch_changed": "Modifié le {when}", diff --git a/client/src/i18n/locales/hi.ts b/client/src/i18n/locales/hi.ts index 1c2924842..7f49f4039 100644 --- a/client/src/i18n/locales/hi.ts +++ b/client/src/i18n/locales/hi.ts @@ -7710,10 +7710,10 @@ helper_copies_failed_body: "अब भी पुराना हेल्पर: "rp_keyboard_hint": "Enter: हो गया। Esc: रद्द करें। जब तक आप यहाँ टाइप करते हैं, गेम को कोई कुंजी या कंट्रोलर दबाव नहीं मिलता।", "rp_settings_paused": "सेटिंग्स खुली रहने तक गेम को कोई कुंजी या कंट्रोलर का दबाव नहीं मिलता।", "rp_picture_tools": "चित्र के टूल", - "saves_switch_title": "Switch गेम (ProsperoEden)", - "saves_switch_running": "ProsperoEden चल रहा है। रीस्टोर करने से पहले इसे बंद करें।", - "saves_switch_close_note": "रीस्टोर करने से पहले ProsperoEden बंद करें।", - "saves_switch_badge": "Switch", + "saves_switch_title": "{platform} गेम ({emulator})", + "saves_switch_running": "{emulator} चल रहा है। रीस्टोर करने से पहले इसे बंद करें।", + "saves_switch_close_note": "रीस्टोर करने से पहले {emulator} बंद करें।", + "saves_switch_badge": "{platform}", "saves_switch_console": "कंसोल", "saves_switch_profile": "प्रोफ़ाइल {id}", "saves_switch_changed": "आख़िरी बदलाव {when}", diff --git a/client/src/i18n/locales/hu.ts b/client/src/i18n/locales/hu.ts index 1a02972d2..5501ab2e1 100644 --- a/client/src/i18n/locales/hu.ts +++ b/client/src/i18n/locales/hu.ts @@ -7988,10 +7988,10 @@ helper_copies_failed_body: "Még mindig a régi segédprogram: {list}. A PS5 min "rp_keyboard_hint": "Enter: kész. Esc: mégse. Amíg itt gépelsz, a játék nem kap billentyűt és kontrollergombot.", "rp_settings_paused": "Amíg a Beállítások nyitva vannak, a játék nem kap billentyűt és kontrollergombot.", "rp_picture_tools": "Képeszközök", - "saves_switch_title": "Switch-játékok (ProsperoEden)", - "saves_switch_running": "A ProsperoEden fut. Zárd be visszaállítás előtt.", - "saves_switch_close_note": "Zárd be a ProsperoEdent visszaállítás előtt.", - "saves_switch_badge": "Switch", + "saves_switch_title": "{platform}-játékok ({emulator})", + "saves_switch_running": "A {emulator} fut. Zárd be visszaállítás előtt.", + "saves_switch_close_note": "Zárd be a {emulator}t visszaállítás előtt.", + "saves_switch_badge": "{platform}", "saves_switch_console": "Konzol", "saves_switch_profile": "{id} profil", "saves_switch_changed": "Utolsó módosítás: {when}", diff --git a/client/src/i18n/locales/id.ts b/client/src/i18n/locales/id.ts index a175864c7..b75701c1b 100644 --- a/client/src/i18n/locales/id.ts +++ b/client/src/i18n/locales/id.ts @@ -7705,10 +7705,10 @@ helper_copies_failed_body: "Masih helper lama: {list}. PS5 menjalankannya lagi s "rp_keyboard_hint": "Enter: selesai. Esc: batal. Selama Anda mengetik di sini, game tidak menerima tombol keyboard atau kontroler.", "rp_settings_paused": "Game tidak menerima tombol keyboard atau kontroler selama Pengaturan terbuka.", "rp_picture_tools": "Alat gambar", - "saves_switch_title": "Game Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden sedang berjalan. Tutup sebelum memulihkan.", - "saves_switch_close_note": "Tutup ProsperoEden sebelum memulihkan.", - "saves_switch_badge": "Switch", + "saves_switch_title": "Game {platform} ({emulator})", + "saves_switch_running": "{emulator} sedang berjalan. Tutup sebelum memulihkan.", + "saves_switch_close_note": "Tutup {emulator} sebelum memulihkan.", + "saves_switch_badge": "{platform}", "saves_switch_console": "Konsol", "saves_switch_profile": "Profil {id}", "saves_switch_changed": "Terakhir diubah {when}", diff --git a/client/src/i18n/locales/it.ts b/client/src/i18n/locales/it.ts index 096c1c14e..91fa62d45 100644 --- a/client/src/i18n/locales/it.ts +++ b/client/src/i18n/locales/it.ts @@ -7649,10 +7649,10 @@ helper_copies_failed_body: "Ancora il vecchio helper: {list}. La PS5 lo riavvia "rp_keyboard_hint": "Invio: fatto. Esc: annulla. Mentre scrivi qui, il gioco non riceve tasti né pressioni del controller.", "rp_settings_paused": "Mentre le Impostazioni sono aperte il gioco non riceve tasti né pressioni del controller.", "rp_picture_tools": "Strumenti immagine", - "saves_switch_title": "Giochi Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden è aperto. Chiudilo prima di ripristinare.", - "saves_switch_close_note": "Chiudi ProsperoEden prima di ripristinare.", - "saves_switch_badge": "Switch", + "saves_switch_title": "Giochi {platform} ({emulator})", + "saves_switch_running": "{emulator} è aperto. Chiudilo prima di ripristinare.", + "saves_switch_close_note": "Chiudi {emulator} prima di ripristinare.", + "saves_switch_badge": "{platform}", "saves_switch_console": "Console", "saves_switch_profile": "Profilo {id}", "saves_switch_changed": "Ultima modifica {when}", diff --git a/client/src/i18n/locales/ja.ts b/client/src/i18n/locales/ja.ts index 60ba5916c..78537abce 100644 --- a/client/src/i18n/locales/ja.ts +++ b/client/src/i18n/locales/ja.ts @@ -7715,10 +7715,10 @@ helper_copies_failed_body: "古いヘルパーのままです: {list}。PS5 は "rp_keyboard_hint": "Enter で完了、Esc でキャンセル。ここで入力している間、キーやコントローラーの入力はゲームに送られません。", "rp_settings_paused": "設定を開いている間、キーやコントローラーの入力はゲームに送られません。", "rp_picture_tools": "映像ツール", - "saves_switch_title": "Switch のゲーム (ProsperoEden)", - "saves_switch_running": "ProsperoEden が起動中です。復元する前に閉じてください。", - "saves_switch_close_note": "復元する前に ProsperoEden を閉じてください。", - "saves_switch_badge": "Switch", + "saves_switch_title": "{platform} のゲーム ({emulator})", + "saves_switch_running": "{emulator} が起動中です。復元する前に閉じてください。", + "saves_switch_close_note": "復元する前に {emulator} を閉じてください。", + "saves_switch_badge": "{platform}", "saves_switch_console": "本体", "saves_switch_profile": "プロファイル {id}", "saves_switch_changed": "最終更新 {when}", diff --git a/client/src/i18n/locales/ko.ts b/client/src/i18n/locales/ko.ts index 5f5d61e91..261abf775 100644 --- a/client/src/i18n/locales/ko.ts +++ b/client/src/i18n/locales/ko.ts @@ -7713,10 +7713,10 @@ helper_copies_failed_body: "여전히 이전 헬퍼입니다: {list}. PS5는 재 "rp_keyboard_hint": "Enter: 완료, Esc: 취소. 여기에 입력하는 동안 게임에는 키나 컨트롤러 입력이 전달되지 않습니다.", "rp_settings_paused": "설정이 열려 있는 동안에는 키와 컨트롤러 입력이 게임에 전달되지 않습니다.", "rp_picture_tools": "화면 도구", - "saves_switch_title": "Switch 게임 (ProsperoEden)", - "saves_switch_running": "ProsperoEden이 실행 중입니다. 복원하기 전에 닫으세요.", - "saves_switch_close_note": "복원하기 전에 ProsperoEden을 닫으세요.", - "saves_switch_badge": "Switch", + "saves_switch_title": "{platform} 게임 ({emulator})", + "saves_switch_running": "{emulator}이 실행 중입니다. 복원하기 전에 닫으세요.", + "saves_switch_close_note": "복원하기 전에 {emulator}을 닫으세요.", + "saves_switch_badge": "{platform}", "saves_switch_console": "본체", "saves_switch_profile": "프로필 {id}", "saves_switch_changed": "마지막 변경 {when}", diff --git a/client/src/i18n/locales/pl.ts b/client/src/i18n/locales/pl.ts index 4f031a51b..36b2a2742 100644 --- a/client/src/i18n/locales/pl.ts +++ b/client/src/i18n/locales/pl.ts @@ -7933,10 +7933,10 @@ helper_copies_failed_body: "Nadal stary pomocnik: {list}. PS5 uruchamia go ponow "rp_keyboard_hint": "Enter: gotowe. Esc: anuluj. Gdy piszesz tutaj, gra nie dostaje klawiszy ani naciśnięć kontrolera.", "rp_settings_paused": "Gdy Ustawienia są otwarte, gra nie dostaje klawiszy ani przycisków kontrolera.", "rp_picture_tools": "Narzędzia obrazu", - "saves_switch_title": "Gry Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden jest uruchomiony. Zamknij go przed przywróceniem.", - "saves_switch_close_note": "Zamknij ProsperoEden przed przywróceniem.", - "saves_switch_badge": "Switch", + "saves_switch_title": "Gry {platform} ({emulator})", + "saves_switch_running": "{emulator} jest uruchomiony. Zamknij go przed przywróceniem.", + "saves_switch_close_note": "Zamknij {emulator} przed przywróceniem.", + "saves_switch_badge": "{platform}", "saves_switch_console": "Konsola", "saves_switch_profile": "Profil {id}", "saves_switch_changed": "Ostatnia zmiana {when}", diff --git a/client/src/i18n/locales/pt-BR.ts b/client/src/i18n/locales/pt-BR.ts index 652945f2b..430fac9c5 100644 --- a/client/src/i18n/locales/pt-BR.ts +++ b/client/src/i18n/locales/pt-BR.ts @@ -7711,10 +7711,10 @@ helper_copies_failed_body: "Ainda é o auxiliar antigo: {list}. O PS5 o inicia d "rp_keyboard_hint": "Enter: concluir. Esc: cancelar. Enquanto você digita aqui, o jogo não recebe teclas nem botões do controle.", "rp_settings_paused": "O jogo não recebe teclas nem botões do controle enquanto as Configurações estão abertas.", "rp_picture_tools": "Ferramentas de imagem", - "saves_switch_title": "Jogos de Switch (ProsperoEden)", - "saves_switch_running": "O ProsperoEden está aberto. Feche-o antes de restaurar.", - "saves_switch_close_note": "Feche o ProsperoEden antes de restaurar.", - "saves_switch_badge": "Switch", + "saves_switch_title": "Jogos de {platform} ({emulator})", + "saves_switch_running": "O {emulator} está aberto. Feche-o antes de restaurar.", + "saves_switch_close_note": "Feche o {emulator} antes de restaurar.", + "saves_switch_badge": "{platform}", "saves_switch_console": "Console", "saves_switch_profile": "Perfil {id}", "saves_switch_changed": "Última alteração {when}", diff --git a/client/src/i18n/locales/ru.ts b/client/src/i18n/locales/ru.ts index 7a8db016e..9ffa99a64 100644 --- a/client/src/i18n/locales/ru.ts +++ b/client/src/i18n/locales/ru.ts @@ -7649,10 +7649,10 @@ helper_copies_failed_body: "По-прежнему старый помощник: "rp_keyboard_hint": "Enter — готово. Esc — отмена. Пока вы печатаете здесь, игра не получает ни клавиш, ни нажатий контроллера.", "rp_settings_paused": "Пока открыты настройки, игра не получает нажатий клавиш и контроллера.", "rp_picture_tools": "Инструменты изображения", - "saves_switch_title": "Игры Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden запущен. Закройте его перед восстановлением.", - "saves_switch_close_note": "Закройте ProsperoEden перед восстановлением.", - "saves_switch_badge": "Switch", + "saves_switch_title": "Игры {platform} ({emulator})", + "saves_switch_running": "{emulator} запущен. Закройте его перед восстановлением.", + "saves_switch_close_note": "Закройте {emulator} перед восстановлением.", + "saves_switch_badge": "{platform}", "saves_switch_console": "Консоль", "saves_switch_profile": "Профиль {id}", "saves_switch_changed": "Изменено {when}", diff --git a/client/src/i18n/locales/th.ts b/client/src/i18n/locales/th.ts index de89cf283..21f705aaa 100644 --- a/client/src/i18n/locales/th.ts +++ b/client/src/i18n/locales/th.ts @@ -7703,10 +7703,10 @@ helper_copies_failed_body: "ยังเป็นตัวช่วยเก่ "rp_keyboard_hint": "Enter: เสร็จ Esc: ยกเลิก ระหว่างที่พิมพ์ตรงนี้ เกมจะไม่ได้รับปุ่มคีย์บอร์ดหรือการกดจอย", "rp_settings_paused": "ขณะเปิดการตั้งค่า เกมจะไม่ได้รับการกดปุ่มคีย์บอร์ดหรือคอนโทรลเลอร์", "rp_picture_tools": "เครื่องมือภาพ", - "saves_switch_title": "เกม Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden กำลังทำงาน ปิดก่อนกู้คืน", - "saves_switch_close_note": "ปิด ProsperoEden ก่อนกู้คืน", - "saves_switch_badge": "Switch", + "saves_switch_title": "เกม {platform} ({emulator})", + "saves_switch_running": "{emulator} กำลังทำงาน ปิดก่อนกู้คืน", + "saves_switch_close_note": "ปิด {emulator} ก่อนกู้คืน", + "saves_switch_badge": "{platform}", "saves_switch_console": "เครื่อง", "saves_switch_profile": "โปรไฟล์ {id}", "saves_switch_changed": "เปลี่ยนล่าสุด {when}", diff --git a/client/src/i18n/locales/tr.ts b/client/src/i18n/locales/tr.ts index a3011d699..4993f0a0b 100644 --- a/client/src/i18n/locales/tr.ts +++ b/client/src/i18n/locales/tr.ts @@ -7703,10 +7703,10 @@ helper_copies_failed_body: "Hâlâ eski yardımcı: {list}. PS5 her yeniden baş "rp_keyboard_hint": "Enter: bitti. Esc: iptal. Burada yazarken oyun tuş veya kumanda basışı almaz.", "rp_settings_paused": "Ayarlar açıkken oyun hiçbir tuş ya da kumanda basışı almaz.", "rp_picture_tools": "Görüntü araçları", - "saves_switch_title": "Switch oyunları (ProsperoEden)", - "saves_switch_running": "ProsperoEden açık. Geri yüklemeden önce kapatın.", - "saves_switch_close_note": "Geri yüklemeden önce ProsperoEden'i kapatın.", - "saves_switch_badge": "Switch", + "saves_switch_title": "{platform} oyunları ({emulator})", + "saves_switch_running": "{emulator} açık. Geri yüklemeden önce kapatın.", + "saves_switch_close_note": "Geri yüklemeden önce {emulator}'i kapatın.", + "saves_switch_badge": "{platform}", "saves_switch_console": "Konsol", "saves_switch_profile": "Profil {id}", "saves_switch_changed": "Son değişiklik {when}", diff --git a/client/src/i18n/locales/vi.ts b/client/src/i18n/locales/vi.ts index f66557880..61855c45e 100644 --- a/client/src/i18n/locales/vi.ts +++ b/client/src/i18n/locales/vi.ts @@ -7698,10 +7698,10 @@ helper_copies_failed_body: "Vẫn là trình trợ giúp cũ: {list}. PS5 sẽ c "rp_keyboard_hint": "Enter: xong. Esc: hủy. Khi bạn gõ ở đây, trò chơi không nhận phím hay nút tay cầm.", "rp_settings_paused": "Khi Cài đặt đang mở, trò chơi không nhận phím hay nút tay cầm nào.", "rp_picture_tools": "Công cụ hình ảnh", - "saves_switch_title": "Game Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden đang chạy. Hãy đóng nó trước khi khôi phục.", - "saves_switch_close_note": "Đóng ProsperoEden trước khi khôi phục.", - "saves_switch_badge": "Switch", + "saves_switch_title": "Game {platform} ({emulator})", + "saves_switch_running": "{emulator} đang chạy. Hãy đóng nó trước khi khôi phục.", + "saves_switch_close_note": "Đóng {emulator} trước khi khôi phục.", + "saves_switch_badge": "{platform}", "saves_switch_console": "Máy", "saves_switch_profile": "Hồ sơ {id}", "saves_switch_changed": "Thay đổi lần cuối {when}", diff --git a/client/src/i18n/locales/zh-CN.ts b/client/src/i18n/locales/zh-CN.ts index 0d7864e82..977a55a14 100644 --- a/client/src/i18n/locales/zh-CN.ts +++ b/client/src/i18n/locales/zh-CN.ts @@ -7655,10 +7655,10 @@ helper_copies_failed_body: "仍是旧助手:{list}。PS5 每次重启后都会 "rp_keyboard_hint": "Enter:完成。Esc:取消。在这里输入时,游戏收不到按键或手柄操作。", "rp_settings_paused": "设置打开时,游戏不会收到任何按键或手柄输入。", "rp_picture_tools": "画面工具", - "saves_switch_title": "Switch 游戏(ProsperoEden)", - "saves_switch_running": "ProsperoEden 正在运行。恢复前请先关闭它。", - "saves_switch_close_note": "恢复前请先关闭 ProsperoEden。", - "saves_switch_badge": "Switch", + "saves_switch_title": "{platform} 游戏({emulator})", + "saves_switch_running": "{emulator} 正在运行。恢复前请先关闭它。", + "saves_switch_close_note": "恢复前请先关闭 {emulator}。", + "saves_switch_badge": "{platform}", "saves_switch_console": "主机", "saves_switch_profile": "配置文件 {id}", "saves_switch_changed": "最后更改 {when}", diff --git a/client/src/i18n/locales/zh-TW.ts b/client/src/i18n/locales/zh-TW.ts index 4af435c16..3e9823f61 100644 --- a/client/src/i18n/locales/zh-TW.ts +++ b/client/src/i18n/locales/zh-TW.ts @@ -7649,10 +7649,10 @@ helper_copies_failed_body: "仍是舊助手:{list}。PS5 每次重新啟動後 "rp_keyboard_hint": "Enter:完成。Esc:取消。在這裡輸入時,遊戲收不到按鍵或控制器操作。", "rp_settings_paused": "設定開啟時,遊戲不會收到任何按鍵或控制器輸入。", "rp_picture_tools": "畫面工具", - "saves_switch_title": "Switch 遊戲(ProsperoEden)", - "saves_switch_running": "ProsperoEden 正在執行。還原前請先關閉它。", - "saves_switch_close_note": "還原前請先關閉 ProsperoEden。", - "saves_switch_badge": "Switch", + "saves_switch_title": "{platform} 遊戲({emulator})", + "saves_switch_running": "{emulator} 正在執行。還原前請先關閉它。", + "saves_switch_close_note": "還原前請先關閉 {emulator}。", + "saves_switch_badge": "{platform}", "saves_switch_console": "主機", "saves_switch_profile": "設定檔 {id}", "saves_switch_changed": "最後變更 {when}", diff --git a/client/src/screens/Saves/SwitchSaves.tsx b/client/src/screens/Saves/SwitchSaves.tsx index f2ae9f2bb..d8fb4db15 100644 --- a/client/src/screens/Saves/SwitchSaves.tsx +++ b/client/src/screens/Saves/SwitchSaves.tsx @@ -19,13 +19,12 @@ import { humanizeCaught } from "../../lib/humanizeError"; /** The profile folder's number as the engine gives it (its first 7 hex digits; 0 for the * console's own save), as a label's id. */ export function profileHex(userId: number): string { - return (userId >>> 0).toString(16).toUpperCase().padStart(7, "0"); + return (userId & 0x0fffffff).toString(16).toUpperCase().padStart(7, "0"); } -/** The Switch games' saves of ProsperoEden (PPSA99008), with their backups: shown only when the +/** The Switch emulators' per-game saves, grouped by their writer: shown only when the * console has one. No game names are known, so each shows its 16-hex-digit title ID. */ export default function SwitchSaves({ host, refreshKey }: { host: string; refreshKey: number }) { - const tr = useTr(); const [saves, setSaves] = useState<SwitchSave[]>([]); useEffect(() => { @@ -42,15 +41,37 @@ export default function SwitchSaves({ host, refreshKey }: { host: string; refres }, [host, refreshKey]); if (saves.length === 0) return null; + const emulators = [...new Set(saves.map((s) => s.emulator || "ProsperoEden"))]; + return ( + <> + {emulators.map((emulator) => ( + <SwitchSaveGroup + key={emulator} + host={host} + emulator={emulator} + saves={saves.filter((s) => (s.emulator || "ProsperoEden") === emulator)} + /> + ))} + </> + ); +} + +function SwitchSaveGroup({ host, saves, emulator }: { + host: string; + saves: SwitchSave[]; + emulator: string; +}) { + const tr = useTr(); + const platform = emulator === "EglantinePS5" ? "Switch / Switch 2" : "Switch"; const running = saves.some((s) => s.running === true); const games = [...new Set(saves.map((s) => s.title_id))].sort(); return ( - <section className="surface-panel mt-3 p-5" data-testid="switch-saves"> + <section className="surface-panel mt-3 p-5" data-testid="switch-saves" data-emulator={emulator}> <header className="mb-1 flex items-center gap-2"> <Gamepad2 size={16} aria-hidden /> <h3 className="text-sm font-semibold"> - {tr("saves_switch_title", undefined, "Switch games (ProsperoEden)")} + {tr("saves_switch_title", { emulator, platform }, "{platform} games ({emulator})")} </h3> </header> <p @@ -63,10 +84,10 @@ export default function SwitchSaves({ host, refreshKey }: { host: string; refres {running ? tr( "saves_switch_running", - undefined, - "ProsperoEden is running. Close it before restoring.", + { emulator }, + "{emulator} is running. Close it before restoring.", ) - : tr("saves_switch_close_note", undefined, "Close ProsperoEden before restoring.")} + : tr("saves_switch_close_note", { emulator }, "Close {emulator} before restoring.")} </p> <div className="space-y-3"> {games.map((game) => ( @@ -74,7 +95,7 @@ export default function SwitchSaves({ host, refreshKey }: { host: string; refres <div className="mb-1 flex items-center gap-2"> <code className="text-sm font-semibold">{game}</code> <span className="rounded bg-[var(--color-surface-3)] px-1.5 py-0.5 text-xs"> - {tr("saves_switch_badge", undefined, "Switch")} + {tr("saves_switch_badge", { platform }, "{platform}")} </span> </div> <ul className="space-y-2"> @@ -106,7 +127,7 @@ function SwitchSaveRow({ host, save }: { host: string; save: SwitchSave }) { kind: save.kind, }; const profile = - save.user_id === 0 + (save.user_id & 0x0fffffff) === 0 ? tr("saves_switch_console", undefined, "Console") : tr("saves_switch_profile", { id: profileHex(save.user_id) }, "Profile {id}"); diff --git a/engine/crates/ps5upload-engine/src/emulator_saves.rs b/engine/crates/ps5upload-engine/src/emulator_saves.rs index 795282d69..a9c21f559 100644 --- a/engine/crates/ps5upload-engine/src/emulator_saves.rs +++ b/engine/crates/ps5upload-engine/src/emulator_saves.rs @@ -1,10 +1,10 @@ -//! The saves of ProsperoEden, the Switch emulator for the PS5 (PPSA99008, or PPSA99016 for its -//! mirror), for the automatic save backups. The emulator keeps them as plain files, not as PS5 -//! save images, one folder per profile and game: -//! `/data/prosperoeden/user/nand/user/save/0000000000000000/<profile>/<game>/`, the -//! profile as 32 hex digits (all zeros: a game's save for the whole console) and the game as its -//! 16-hex-digit title ID. That place is fixed in the emulator: the game files folder chosen in its -//! settings moves the games, keys and firmware, never the saves. +//! The saves of the Switch emulators ProsperoEden (PPSA99008, or PPSA99016 for its mirror) +//! and EglantinePS5 (PPSA98515), for the automatic save backups. Both keep plain files rather +//! than PS5 save images, one folder per profile and game: +//! `/data/prosperoeden/user/nand/user/save/0000000000000000/<profile>/<game>/`, with +//! the same layout under `/data/eglantineps5` for EglantinePS5. A profile is 32 hex digits +//! (all zeros for a game's console-wide save); a game is its 16-hex-digit title ID. These +//! locations are fixed: the game files setting moves games, keys and firmware, never saves. //! //! Each such folder that holds a file is listed among a console's saves (`kind` "switch", //! `title_id` the game's), so it is backed up, kept and restored as a PS5 save is, with two @@ -33,6 +33,48 @@ pub const MIRROR: &str = "PPSA99016"; pub const KIND: &str = "switch"; /// Where it keeps every profile's saves. pub const ROOT: &str = "/data/prosperoeden/user/nand/user/save/0000000000000000"; +/// EglantinePS5 keeps the same save layout in its own data folder. +pub const EGLANTINE_APP: &str = "PPSA98515"; +pub const EGLANTINE_ROOT: &str = "/data/eglantineps5/user/nand/user/save/0000000000000000"; +/// The lower 28 bits keep the existing profile number. Bit 28 separates Eglantine's backups +/// (names, retention and listings) from ProsperoEden's, even for the same profile and game. +const EGLANTINE_USER: i32 = 0x1000_0000; + +#[derive(Clone, Copy)] +pub(crate) struct Emulator { + pub app: &'static str, + pub name: &'static str, + root: &'static str, + user_namespace: i32, +} + +const EMULATORS: [Emulator; 2] = [ + Emulator { + app: APP, + name: "ProsperoEden", + root: ROOT, + user_namespace: 0, + }, + Emulator { + app: EGLANTINE_APP, + name: "EglantinePS5", + root: EGLANTINE_ROOT, + user_namespace: EGLANTINE_USER, + }, +]; + +/// An exact per-game save path, its writer, and its backup user number. +pub(crate) fn place_of(path: &str) -> Option<(Emulator, i32)> { + EMULATORS.iter().find_map(|emulator| { + let (profile, game) = path + .strip_prefix(emulator.root)? + .strip_prefix('/')? + .split_once('/')?; + (is_profile(profile) && is_game(game)) + .then(|| (*emulator, user_of(profile) | emulator.user_namespace)) + }) +} + /// How many folders down a game's save is looked into for its newest file. pub const DEPTH: u32 = 4; @@ -56,12 +98,9 @@ pub fn is_emulator_save(e: &SaveEntry) -> bool { e.kind == KIND || crate::ps2_saves::is_kind(&e.kind) } -/// `path` is a save folder of the emulator, `ROOT/<profile>/<game>`, and nothing past it. +/// `path` is exactly a per-game save folder under either emulator's root. pub fn is_save_path(path: &str) -> bool { - path.strip_prefix(ROOT) - .and_then(|rest| rest.strip_prefix('/')) - .and_then(|rest| rest.split_once('/')) - .is_some_and(|(profile, game)| is_profile(profile) && is_game(game)) + place_of(path).is_some() } /// The kind of emulator's save `path` is the folder of; None for a PS5 save's. @@ -73,11 +112,11 @@ pub fn kind_of_path(path: &str) -> Option<&'static str> { } } -/// The app that writes the save: ProsperoEden for its saves, the game itself for a PS5 one. (A +/// The app that writes the save: its Switch emulator, or the game itself for a PS5 save. (A /// PlayStation or PlayStation 2 emulator's saves are under its own title already.) pub fn app_of(e: &SaveEntry) -> &str { if e.kind == KIND { - APP + place_of(&e.path).map_or(APP, |(emulator, _)| emulator.app) } else { &e.title_id } @@ -144,19 +183,30 @@ fn all_pages(page: &dyn Fn(u64) -> Result<DirListing, String>) -> Result<Vec<Dir /// [`list`], with `ls` giving the entries of a folder on the console. pub fn saves_in(ls: &dyn Fn(&str) -> Result<Vec<DirEntry>, String>) -> Vec<SaveEntry> { + EMULATORS + .iter() + .flat_map(|emulator| saves_at(ls, *emulator)) + .collect() +} + +fn saves_at( + ls: &dyn Fn(&str) -> Result<Vec<DirEntry>, String>, + emulator: Emulator, +) -> Vec<SaveEntry> { let mut out = Vec::new(); - let Ok(profiles) = ls(ROOT) else { + let root = emulator.root; + let Ok(profiles) = ls(root) else { return out; }; for p in profiles .iter() .filter(|p| p.kind == "dir" && is_profile(&p.name)) { - let Ok(games) = ls(&format!("{ROOT}/{}", p.name)) else { + let Ok(games) = ls(&format!("{root}/{}", p.name)) else { continue; }; for g in games.iter().filter(|g| g.kind == "dir" && is_game(&g.name)) { - let path = format!("{ROOT}/{}/{}", p.name, g.name); + let path = format!("{root}/{}/{}", p.name, g.name); // A folder not read whole waits for the next look: its newest time could miss the // file the game wrote. let Ok((size, mtime, files)) = measure(ls, &path, g.mtime, DEPTH) else { @@ -169,7 +219,7 @@ pub fn saves_in(ls: &dyn Fn(&str) -> Result<Vec<DirEntry>, String>) -> Vec<SaveE } out.push(SaveEntry { title_id: g.name.clone(), - user_id: user_of(&p.name), + user_id: user_of(&p.name) | emulator.user_namespace, path, size: size as i64, mtime, @@ -225,6 +275,8 @@ pub struct SwitchQuery { pub struct SwitchSave { #[serde(flatten)] pub save: SaveEntry, + /// The emulator that owns this save folder. + pub emulator: &'static str, /// The emulator runs now (its saves cannot be restored meanwhile); None when the console did /// not say. pub running: Option<bool>, @@ -240,24 +292,36 @@ pub async fn get_switch(Query(q): Query<SwitchQuery>) -> Response { } let r = tokio::task::spawn_blocking(move || { let saves = list(&host); - // Only asked when there is something to restore. - let running = if saves.is_empty() { + // Asked once for each emulator that has saves, independently of the other emulator. + let mut running = std::collections::BTreeMap::new(); + let saves = saves + .into_iter() + .map(|save| { + let (emulator, _) = place_of(&save.path).expect("listed Switch save path"); + let run = *running.entry(emulator.app).or_insert_with(|| { + crate::save_backup::running_of(&host, &titles_of(emulator.app)) + .map(|t| t.is_some()) + .ok() + }); + SwitchSave { + save, + emulator: emulator.name, + running: run, + } + }) + .collect::<Vec<_>>(); + let any_running = if saves.is_empty() || saves.iter().any(|s| s.running.is_none()) { None } else { - crate::save_backup::running_of(&host, &titles_of(APP)) - .map(|t| t.is_some()) - .ok() + Some(saves.iter().any(|s| s.running == Some(true))) }; - (saves, running) + (saves, any_running) }) .await; match r { Ok((saves, running)) => Json(json!({ "running": running, "saves": saves - .into_iter() - .map(|save| SwitchSave { save, running }) - .collect::<Vec<_>>(), })) .into_response(), Err(e) => crate::save_backup::json_error(StatusCode::INTERNAL_SERVER_ERROR, e.to_string()), @@ -379,6 +443,7 @@ mod tests { let save = saves_in(&ls_of(&fs)).remove(0); let v = serde_json::to_value(SwitchSave { save, + emulator: "ProsperoEden", running: Some(true), }) .unwrap(); @@ -388,6 +453,81 @@ mod tests { assert_eq!(v["running"], true); } + #[test] + fn eglantine_and_eden_keep_the_same_game_and_profile_separate() { + let mut fs = console(); + for (path, entries) in console() { + fs.insert(path.replacen(ROOT, EGLANTINE_ROOT, 1), entries); + } + let saves = saves_in(&ls_of(&fs)); + assert_eq!(saves.len(), 4); + let eden = &saves[0]; + let eglantine = &saves[2]; + assert_eq!(eglantine.title_id, eden.title_id); + assert_eq!(eglantine.size, eden.size); + assert_eq!(eglantine.mtime, 500); + assert_eq!(eglantine.user_id, eden.user_id | EGLANTINE_USER); + assert_eq!(saves[3].user_id, EGLANTINE_USER); // console-wide save + assert_eq!(app_of(eglantine), EGLANTINE_APP); + assert_eq!(titles_of(app_of(eglantine)), [EGLANTINE_APP]); + assert_eq!(titles_of(app_of(eden)), [APP, MIRROR]); + let name = |save: &SaveEntry| { + ps5upload_core::save_archive::auto_backup_stem(&save.title_id, save.user_id as u32) + }; + assert_ne!(name(eden), name(eglantine)); + // The keep limit must never prune the other emulator's version of this profile. + let files: Vec<_> = [eden, eglantine] + .into_iter() + .flat_map(|save| { + ["2026-11-01_000000", "2026-11-02_000000"].map(|stamp| crate::save_layout::Found { + dir: GAME.into(), + name: format!("{}{stamp}.zip", name(save)), + size: 1, + }) + }) + .collect(); + for save in [eden, eglantine] { + let old = crate::save_layout::to_prune(&files, GAME, save.user_id as u32, None, 1); + assert_eq!(old.len(), 1); + assert_eq!(old[0].name, format!("{}2026-11-01_000000.zip", name(save))); + } + + assert!(saves + .iter() + .all(|s| is_save_path(&s.path) && kind_of_path(&s.path) == Some(KIND))); + let json = serde_json::to_value(SwitchSave { + save: eglantine.clone(), + emulator: "EglantinePS5", + running: Some(false), + }) + .unwrap(); + assert_eq!(json["emulator"], "EglantinePS5"); + assert_eq!(json["running"], false); + } + + #[test] + fn eglantine_is_optional_and_its_paths_are_exact() { + let mut fs: BTreeMap<_, _> = console() + .into_iter() + .map(|(p, e)| (p.replacen(ROOT, EGLANTINE_ROOT, 1), e)) + .collect(); + assert_eq!(saves_in(&ls_of(&fs)).len(), 2); + let path = format!("{EGLANTINE_ROOT}/{P1}/{GAME}"); + for bad in [ + format!("{path}/slot_00"), + format!("{path}.backup-20261124"), + format!("{EGLANTINE_ROOT}/{P1}/../{GAME}"), + path.replacen("/data/eglantineps5/", "/data/eglantineps5-other/", 1), + ] { + assert!(place_of(&bad).is_none(), "{bad}"); + } + fs.insert(path.clone(), vec![]); + assert_eq!(saves_in(&ls_of(&fs)).len(), 1); + fs.insert(path.clone(), vec![entry("slots", "dir", 0, 500)]); + fs.remove(&format!("{path}/slots")); + assert_eq!(saves_in(&ls_of(&fs)).len(), 1); // unreadable subfolder + } + #[test] fn a_big_folder_is_read_page_by_page() { let all: Vec<DirEntry> = (0..300) diff --git a/engine/crates/ps5upload-engine/src/save_backup.rs b/engine/crates/ps5upload-engine/src/save_backup.rs index f5b81d86b..512d0fab7 100644 --- a/engine/crates/ps5upload-engine/src/save_backup.rs +++ b/engine/crates/ps5upload-engine/src/save_backup.rs @@ -1741,8 +1741,15 @@ pub(crate) fn save_writer<'a>( user_id: u32, ) -> Result<Writer<'a>, String> { let ps2 = crate::ps2_saves::place_of(save_path); + let switch = crate::emulator_saves::place_of(save_path); let fits = match &ps2 { Some(p) => p.emulator.app == title_id && p.user as u32 == user_id, + None if switch.is_some() => { + save_path.ends_with(&format!("/{title_id}")) + && switch + .as_ref() + .is_some_and(|(_, user)| *user as u32 == user_id) + } None => save_path.ends_with(&format!("/{title_id}")), }; if !fits { @@ -1753,10 +1760,10 @@ pub(crate) fn save_writer<'a>( app: p.emulator.app, emulator: Some(p.emulator.name), } - } else if crate::emulator_saves::is_save_path(save_path) { + } else if let Some((emulator, _)) = switch { Writer { - app: crate::emulator_saves::APP, - emulator: Some("ProsperoEden"), + app: emulator.app, + emulator: Some(emulator.name), } } else { Writer { @@ -3462,6 +3469,36 @@ mod tests { ); } + #[test] + fn eglantine_waits_for_its_own_writer_and_restores_only_its_profile() { + let path = "/data/eglantineps5/user/nand/user/save/0000000000000000/1F1E1D1C1B1A19181716151413121110/0100F2C0115B6000"; + let entry = SaveEntry { + title_id: "0100F2C0115B6000".into(), + user_id: 0x11f1_e1d1, + path: path.into(), + size: 17, + mtime: 1000, + kind: "switch".into(), + }; + let writer = save_writer(path, &entry.title_id, entry.user_id as u32).unwrap(); + assert_eq!( + (writer.app, writer.emulator), + (crate::emulator_saves::EGLANTINE_APP, Some("EglantinePS5")) + ); + assert!(save_writer(path, &entry.title_id, 0x01f1_e1d1).is_err()); + assert!(save_writer(path, "0100000000000000", entry.user_id as u32).is_err()); + let saves = [entry]; + let busy = [crate::emulator_saves::EGLANTINE_APP.to_string()].into(); + assert!(needing_backup("h", &saves, &Done::new(), 2000, &busy).is_empty()); + for app in [crate::emulator_saves::APP, crate::emulator_saves::MIRROR] { + let busy = [app.to_string()].into(); + assert_eq!( + needing_backup("h", &saves, &Done::new(), 2000, &busy).len(), + 1 + ); + } + } + #[test] fn the_ps2_emulators_cards_and_states_are_backed_up_too() { use crate::ps2_saves::{CARDS_USER, CRUX2, KIND, STATES_USER}; diff --git a/engine/crates/ps5upload-engine/src/save_backup_server.rs b/engine/crates/ps5upload-engine/src/save_backup_server.rs index 1b006454c..a66135d13 100644 --- a/engine/crates/ps5upload-engine/src/save_backup_server.rs +++ b/engine/crates/ps5upload-engine/src/save_backup_server.rs @@ -1709,6 +1709,52 @@ mod tests { assert!(due_saves("h", &[odd], &Done::new(), 2000, &all).is_empty()); } + #[test] + fn eglantine_close_and_running_do_not_select_edens_saves() { + let profile = "1F1E1D1C1B1A19181716151413121110"; + let game = "0100F2C0115B6000"; + let saves = [emulator_saves::ROOT, emulator_saves::EGLANTINE_ROOT].map(|root| SaveEntry { + kind: emulator_saves::KIND.into(), + ..save(&format!("{root}/{profile}/{game}"), game, 1, 1000) + }); + let none = BTreeSet::new(); + let pick = Pick { + users: &[1], + title: Some(emulator_saves::EGLANTINE_APP), + settle: false, + running: &none, + drive_done: None, + }; + let due = due_saves("h", &saves, &Done::new(), 2000, &pick); + assert_eq!(due.len(), 1); + assert_eq!(due[0].path, saves[1].path); + let running = [emulator_saves::EGLANTINE_APP.to_string()].into(); + assert!(due_saves( + "h", + &saves, + &Done::new(), + 2000, + &Pick { + running: &running, + ..pick + } + ) + .is_empty()); + let due = due_saves( + "h", + &saves, + &Done::new(), + 2000, + &Pick { + title: None, + running: &running, + ..pick + }, + ); + assert_eq!(due.len(), 1); + assert_eq!(due[0].path, saves[0].path); + } + #[test] fn ps2_saves_go_with_their_emulator() { let ps2 = |path: &str, user| SaveEntry { diff --git a/scripts/i18n-source-hashes.json b/scripts/i18n-source-hashes.json index a280e892e..e13b587a5 100644 --- a/scripts/i18n-source-hashes.json +++ b/scripts/i18n-source-hashes.json @@ -7793,15 +7793,15 @@ "saves_switch_backup_failed": "f8420160 RehwYKh4x_LbpAm7Gam6zuslIVJnWqU85AVnHwrTcBIWF8wblXn0pfJkqHEH", "saves_switch_backup_hint": "e226a567 gEds--X6ut7O8ryrHLfTg7XBYAN9yLJQpYaPZIJIexLk1qzj8znEK-TkY8UN", "saves_switch_backup_now": "02a2840b -Baq7z8pr8-Mj8mrd9pmQXjPeuS1BrvhT_dwz_dqg9Wj_0bsVgeg_f5cYowT", - "saves_switch_badge": "39921a74 OZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZI", + "saves_switch_badge": "168dcb70 Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3", "saves_switch_changed": "3e627bb7 acs2ffr4WUULlfgu53uFqR3uMd-Y0fcCtRK3Mj74A3mME4mWtfHkMXqB9W0Y", - "saves_switch_close_note": "1c9caed6 H4C76L4Ql7B4_g3b7jtzc-Qnq_7p4_mbVhyimvEQQiGjA87wOLUn70k60XRB", + "saves_switch_close_note": "aaf6f564 Gh39vyhtashHMnXzGBo0tUM5dC0ltO7KEsxKFkOyClMis6Kin4rnPEO4Hlmw", "saves_switch_console": "29a40861 vT7MFJGgS4CNodiKaQpUpYA5vdPKaQ5yXKeX0zZKaQpY9CYAvdPD4P6H2yqN", "saves_switch_need_dir": "6fa9a703 3TwXXJ5T-Wy9XZjiUYk5XmsKKonQa5TJb4jE0WZh9ugbVFxXBN42GoQSSJIJ", "saves_switch_no_backups": "0d123d0d I3iK94NHcVHXrjnYWZVnfmG_IHt-D8ldv9BhtNbxQLw9LTW0SxL0HIr5mcGH", "saves_switch_profile": "fa9c0562 AHE7vx8tEd3BvFt8tEEs1I6v8tEqfhMUfXgh8tEd3BtVixFr8tEjabno26xe", - "saves_switch_running": "5b1c6581 B_8Lme1arslIV4QS3IOJnOQdsY2DCSR-vnfGthVUc59Om5LTvYdFVHpdCQq9", - "saves_switch_title": "36e30a9f Bpt5IwF4MDaS-nc_ZeeP9kZNqrBOB-Ro8o7yBjoo6m_pZYl0pz5qrBMT_3zR", + "saves_switch_running": "9e40f6e3 lGvF_AAG78FGNrv6JMilY0exjFdGMo2vGiwH5XptIoNzE5uYhQegsVulqUTL", + "saves_switch_title": "8fcff65f fQQgKKTwXYEFsEBZRMi7HYcB154qZFkg_butUNYsiK14WpA_W9g154eTdyvY", "saves_sync_add": "98af618b V7ICCESYV02-jLA5yw_XvZlC6-RjmCV74ON95FSahdzBpPU0PTPGc4PMbPMb", "saves_sync_add_another": "d7246da5 ZIsCLuXJv7QwSaT9_0CCoGci6qoj0TjrkuLccVYWq1GUb1IXtPIkLZqAP_OF", "saves_sync_both_changed": "b456b0eb vfyIY-RwD2IR2q_t3inOjFom5FC_xc_7fWO3-6IYa-_5dGexg2HDUNe1XS4-",