Skip to content

Build your personal knowledge base with Trilium Notes

client/backup import: do not enumerate backups in standalone mode

Adorian Dorand1febfbb5450
diff --git a/apps/client/src/setup_restore.spec.tsx b/apps/client/src/setup_restore.spec.tsx
index b3a75f49a0..69e41693a6 100644
--- a/apps/client/src/setup_restore.spec.tsx
+++ b/apps/client/src/setup_restore.spec.tsx
@@ -241,6 +241,16 @@ describe("restoring on standalone", () => {
expect(serverMock.get).not.toHaveBeenCalledWith("setup/restore/status");
});
+ it("offers no list of existing backups, since there are none to offer", async () => {
+ renderRestore();
+ await flushEffects();
+
+ expect(serverMock.get).not.toHaveBeenCalledWith("database/backups");
+ expect(container.textContent).not.toContain("setup.restore-existing-backups");
+ // The way in from a file is the whole screen here.
+ expect(container.querySelector(".restore-choose-file")).toBeTruthy();
+ });
+
it("reports a refusal in the same words every other platform uses", async () => {
importBackup.mockResolvedValue({
status: "error", reason: "database-too-new", message: "The database is version 999."
diff --git a/apps/client/src/setup_restore.tsx b/apps/client/src/setup_restore.tsx
index d57100826f..0d635c0a09 100644
--- a/apps/client/src/setup_restore.tsx
+++ b/apps/client/src/setup_restore.tsx
@@ -70,6 +70,13 @@ export default function RestoreFromBackup({ onBack, onRestored }: { onBack: () =
const [ backups, setBackups ] = useState<DatabaseBackup[] | null>(null);
useEffect(() => {
+ // Standalone keeps no backups worth offering: nothing takes them on a schedule there, and a
+ // copy kept beside the database in the browser's own storage is cleared along with it.
+ if (window.standaloneApi) {
+ setBackups([]);
+ return;
+ }
+
server.get<ExistingBackupsResponse>("database/backups")
.then((response) => setBackups(response.backups))
// An unreadable backup directory is not a reason to lose the way in from a file.