mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 07:18:47 +00:00
Merge pull request #752 from PR0M3TH3AN/codex/update-initialize_managers-method-logic
Prompt sync after migration
This commit is contained in:
@@ -1158,7 +1158,7 @@ class PasswordManager:
|
||||
|
||||
migrated = False
|
||||
try:
|
||||
_, migrated = self.vault.load_index(return_migration_flag=True)
|
||||
self.vault.load_index(return_migration_flag=True)
|
||||
except RuntimeError as exc:
|
||||
print(colored(str(exc), "red"))
|
||||
sys.exit(1)
|
||||
@@ -1222,8 +1222,29 @@ class PasswordManager:
|
||||
delta_since=self.delta_since or None,
|
||||
)
|
||||
|
||||
if migrated and not self.offline_mode:
|
||||
self.start_background_vault_sync()
|
||||
if getattr(self.encryption_manager, "last_migration_performed", False):
|
||||
print(colored("Local database migration successful.", "green"))
|
||||
self.encryption_manager.last_migration_performed = False
|
||||
if not self.offline_mode and confirm_action(
|
||||
"Do you want to sync the migrated profile to Nostr now?"
|
||||
):
|
||||
result = self.sync_vault()
|
||||
if result:
|
||||
print(
|
||||
colored(
|
||||
"Profile synchronized to Nostr successfully.",
|
||||
"green",
|
||||
)
|
||||
)
|
||||
else:
|
||||
print(colored("Error: Failed to sync profile to Nostr.", "red"))
|
||||
elif not self.offline_mode:
|
||||
print(
|
||||
colored(
|
||||
"You can sync the migrated profile later from the main menu.",
|
||||
"yellow",
|
||||
)
|
||||
)
|
||||
|
||||
logger.debug("Managers re-initialized for the new fingerprint.")
|
||||
|
||||
|
@@ -105,13 +105,16 @@ def test_migration_triggers_sync(monkeypatch, tmp_path: Path):
|
||||
pm.bip85 = SimpleNamespace()
|
||||
|
||||
calls = {"sync": 0}
|
||||
pm.start_background_vault_sync = lambda *a, **k: calls.__setitem__(
|
||||
"sync", calls["sync"] + 1
|
||||
)
|
||||
pm.sync_vault = lambda *a, **k: calls.__setitem__("sync", calls["sync"] + 1) or {
|
||||
"manifest_id": "m",
|
||||
"chunk_ids": [],
|
||||
"delta_ids": [],
|
||||
}
|
||||
|
||||
monkeypatch.setattr(
|
||||
"seedpass.core.manager.NostrClient", lambda *a, **k: SimpleNamespace()
|
||||
)
|
||||
monkeypatch.setattr("seedpass.core.manager.confirm_action", lambda *_a, **_k: True)
|
||||
|
||||
pm.initialize_managers()
|
||||
assert calls["sync"] == 1
|
||||
@@ -186,9 +189,13 @@ def test_legacy_index_reinit_triggers_sync_once(monkeypatch, tmp_path: Path):
|
||||
)
|
||||
|
||||
calls = {"sync": 0}
|
||||
pm.start_background_vault_sync = lambda *a, **k: calls.__setitem__(
|
||||
"sync", calls["sync"] + 1
|
||||
)
|
||||
pm.sync_vault = lambda *a, **k: calls.__setitem__("sync", calls["sync"] + 1) or {
|
||||
"manifest_id": "m",
|
||||
"chunk_ids": [],
|
||||
"delta_ids": [],
|
||||
}
|
||||
|
||||
monkeypatch.setattr("seedpass.core.manager.confirm_action", lambda *_a, **_k: True)
|
||||
|
||||
pm.initialize_managers()
|
||||
pm.initialize_managers()
|
||||
|
Reference in New Issue
Block a user