From b68ebd0fd0ce7132577eb05d84933097ca7ddbba Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 25 Nov 2025 15:19:10 -0500 Subject: [PATCH] fix(backup): return error if there is no backup path set Needed for https://github.com/status-im/status-desktop/issues/19377 For Android, we are setting the default path to empty string so that the user can know that they need to modify it. Otherwise, the default path was the datadir and users cannot access it. What this meant is that once the auto-backup was happening, the status-go code worked, but then it failed because of the missing user permission. To fix it, we just throw an error on empty paths in status-go. That way the backup just doesn't happen until the user selects a path. --- node/get_status_node.go | 9 +++------ tests-functional/tests/test_local_backup.py | 7 +++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/node/get_status_node.go b/node/get_status_node.go index ec63829630c..0919703e76f 100644 --- a/node/get_status_node.go +++ b/node/get_status_node.go @@ -259,14 +259,11 @@ func (n *StatusNode) StartLocalBackup() error { return "", err } - var backupDir string - if backupPath != "" { - backupDir = backupPath - } else { - backupDir = filepath.Join(n.config.RootDataDir, "backups") + if backupPath == "" { + return "", errors.New("backup path is not set") } - fullPath := filepath.Join(backupDir, fmt.Sprintf("%s_user_data.bkp", compressedPubKey[len(compressedPubKey)-6:])) + fullPath := filepath.Join(backupPath, fmt.Sprintf("%s_user_data.bkp", compressedPubKey[len(compressedPubKey)-6:])) return fullPath, nil } diff --git a/tests-functional/tests/test_local_backup.py b/tests-functional/tests/test_local_backup.py index 67d347251bb..9af348af69d 100644 --- a/tests-functional/tests/test_local_backup.py +++ b/tests-functional/tests/test_local_backup.py @@ -1,4 +1,5 @@ import os +import re import pytest @@ -6,6 +7,7 @@ from resources.constants import Account, user_1 from resources.test_data import profile_showcase_utils from utils import fake +from clients.api import ApiResponseError test_one_to_one_chat_id = ( "0x043329fc08727f15c4ec9a17bf7d6a3dc44e9d0d8f782a55804f3660b28827194a365dc1765cf96b6fa5cd666b9ee5298e8ac82f51f7952c4110cbf321d4f63864" @@ -194,6 +196,11 @@ def test_local_backup(self, tmp_path): assert group_chat_recovered, "Group chat was not restored correctly" assert one_on_one_chat_recovered, "One-to-one chat was not restored correctly" + # Test that it fails if no backupPath is set + backend_client.settings_service.save_setting("backup-path", "") + with pytest.raises(ApiResponseError, match=re.escape("backup path is not set")): + backend_client.api_request_json("PerformLocalBackup", "") + # Change the backup path (Docker restricts access to a lot of folders) backend_client.settings_service.save_setting("backup-path", "/usr/status-user/backups")